heymo the journey of a module heymo vehse from …...create a report: will create a report...

39
The journey of a module from Drupal 7 to Drupal 8 Heymo Vehse https://twitter.com/heymo https://www.drupal.org/u/heymo

Upload: others

Post on 06-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

The journey of a module from Drupal 7 to Drupal 8

Heymo Vehse

https://twitter.com/heymohttps://www.drupal.org/u/heymo

Page 2: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

About Me

Heymo Vehsehttps://twitter.com/heymo

https://www.drupal.org/u/heymo

[email protected]

Page 3: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

We have an agenda

● The Module

● Tools and Resources

● Steps to Take

Page 4: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

The Module

Page 5: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

“Helpfulness”

(....just ignore the name!)

https://www.drupal.org/project/helpfulness

Page 6: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

It's simple

https://flic.kr/p/nwFSD3

Page 7: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

It does a lot of things

Links and Menus

Form API

Tasks and Tabs

Permissions

Variables

DatabaseBlocks

Stylesheets

JavaScript

Configuration

Reporting

Spam control

Input validation

Page 8: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

The sources we use:

Page 9: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Demo

Page 10: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Tools & Resources

Page 11: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Drupal Module Upgrader

https://www.drupal.org/project/drupalmoduleupgrader

Page 12: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

cd /My/Drupal8/root/drush dl drupalmoduleupgradercd modules/drupalmoduleupgradercomposer installdrush en drupalmoduleupgrader

Drupal Module Upgrader

Install to a Drupal 8 site:

Page 13: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Create a report:

Will create a report “upgrade-info.html ” in your module directory

drush dmu-analyze MODULE_NAME

Drupal Module Upgrader

Page 14: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Drupal Module Upgrader

Page 15: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Change records for Drupal core

https://www.drupal.org/list-changes/drupal

Page 16: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Change records for Drupal core

https://www.drupal.org/list-changes/drupal?keywords_description=&to_branch=8.x

Page 17: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Learn some Symfony

Page 18: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

RTFM

https://www.drupal.org/update/modules/7/8

Page 19: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Try to convert the code:

Drupal Module Upgrader

drush dmu-upgrade MODULE_NAME

Page 20: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Drupal 7: dmu-upgrade:

Page 21: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module
Page 22: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Drupal 7: After cleanup:

Page 23: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

The Steps To Take

Page 24: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Module information

https://flic.kr/p/adF44b

Page 25: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Module information

// helpfulness.info

name = Helpfulnessdescription = Provides a block for the user to leave feedbackcore = "7.x"

Drupal 7:

Page 26: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Module information

// helpfulness.info.yml

name: Helpfulnessdescription: 'Provides a block for the user to leave feedback'core: 8.xtype: module

Drupal 8:

Page 27: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Menu and Routing

https://flic.kr/p/6EUrXT

Page 28: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Menu and Routing

// helpfulness.module

function helpfulness_menu() {

$items['admin/reports/helpfulness'] = array( 'title' => 'Helpfulness Feedback messages', 'description' => 'View messages from the helpfulness module.', 'type' => MENU_NORMAL_ITEM, 'page callback' => 'drupal_get_form', 'page arguments' => array('helpfulness_report_form'), 'access arguments' => array('view helpfulness messages'), 'file' => 'helpfulness.report.inc', );

Drupal 7:

Page 29: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Menu and Routing

# helpfulness.routing.ymlhelpfulness.report_form: path: /admin/reports/helpfulness defaults: _title: 'Helpfulness Feedback messages' _form: \Drupal\helpfulness\Form\HelpfulnessReportForm requirements: _permission: 'view helpfulness messages'

# helpfulness.links.menu.ymlhelpfulness.report_form: route_name: helpfulness.report_form title: 'Helpfulness Feedback messages' description: 'View messages from the helpfulness module.' parent: system.admin_reports

Drupal 8:

Page 30: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Permissions

Page 31: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Permissions

// helpfulness.modulefunction helpfulness_permission() { return array(

/* … */ 'view helpfulness messages' => array( 'title' => t('View feedback messages'), 'description' => t('View and delete helpfulness messages.'), ), );}

function helpfulness_menu() { $items['admin/reports/helpfulness'] = array( 'title' => 'Helpfulness Feedback messages',

/* … */ 'access arguments' => array('view helpfulness messages'), );

Drupal 7:

Page 32: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Permissions

// helpfulness.permissions.yml

'view helpfulness messages': title: 'Access helpfulness feedback report' description: 'View and delete helpfulness messages.'

# helpfulness.routing.ymlhelpfulness.report_form: path: /admin/reports/helpfulness defaults: _title: 'Helpfulness Feedback messages' _form: \Drupal\helpfulness\Form\HelpfulnessReportForm requirements: _permission: 'view helpfulness messages'

Drupal 8:

Page 33: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Forms

Page 34: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Forms

// helpfulness.module

function helpfulness_menu() {

$items['admin/reports/helpfulness'] = array(/* … */

'page arguments' => array('helpfulness_report_form'), 'file' => 'helpfulness.report.inc', );

// helpfulness.report.inc

function helpfulness_report_form($form, &$form_state) {/* …build the form */return $form;

}

Drupal 7:

Page 35: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Forms

// helpfulness.routing.yml

helpfulness.report_form: path: /admin/reports/helpfulness defaults: _title: 'Helpfulness Feedback messages' _form: \Drupal\helpfulness\Form\HelpfulnessReportForm

// /src/Form/HelpfulnessReportForm.phpnamespace Drupal\helpfulness\Form;

class HelpfulnessReportForm extends FormBase {

public function buildForm(array $form, FormStateInterface $form_state){/* …build the form... */return $form;}

}

Drupal 8:

Page 36: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Database Table

https://flic.kr/p/puR46m

Page 37: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

// helpfulness.install

function helpfulness_schema() { $schema['helpfulness'] = array( 'description' => 'Stores all helpfulness messages.', 'fields' => array(

//* all kinds of other fields… */ 'message' => array( 'description' => 'The feedback message.', 'type' => 'text', 'null' => TRUE, ), ),

//* other stuff, like primary keys… */ );

return $schema;}

Drupal 7:

Database Table

Page 38: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Database Table

// helpfulness.install

function helpfulness_schema() { $schema['helpfulness'] = array( 'description' => 'Stores all helpfulness messages.', 'fields' => array(

//* all kinds of other fields… */ 'message' => array( 'description' => 'The feedback message.', 'type' => 'text', 'null' => TRUE, ), ),

//* other stuff, like primary keys… */ );

return $schema;}

Drupal 8 - it’s all the same:

Page 39: heymo The journey of a module Heymo Vehse from …...Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME Drupal Module

Thank you.Questions?

Heymo Vehse

https://twitter.com/heymohttps://www.drupal.org/u/heymo