The journey of a module from Drupal 7 to Drupal 8 Heymo Vehse - - PowerPoint PPT Presentation

the journey of a module from drupal 7 to drupal 8
SMART_READER_LITE
LIVE PREVIEW

The journey of a module from Drupal 7 to Drupal 8 Heymo Vehse - - PowerPoint PPT Presentation

The journey of a module from Drupal 7 to Drupal 8 Heymo Vehse https://twitter.com/heymo https://www.drupal.org/u/heymo About Me Heymo Vehse https://twitter.com/heymo https://www.drupal.org/u/heymo heymo@thebrickfactory.com W e have an


slide-1
SLIDE 1

The journey of a module from Drupal 7 to Drupal 8

Heymo Vehse https://twitter.com/heymo https://www.drupal.org/u/heymo

slide-2
SLIDE 2

About Me

Heymo Vehse

https://twitter.com/heymo https://www.drupal.org/u/heymo heymo@thebrickfactory.com

slide-3
SLIDE 3

We have an agenda

  • The Module
  • Tools and Resources
  • Steps to Take
slide-4
SLIDE 4

The Module

slide-5
SLIDE 5

“Helpfulness”

(....just ignore the name!)

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

slide-6
SLIDE 6

It's simple

https://flic.kr/p/nwFSD3

slide-7
SLIDE 7

It does a lot of things

Links and Menus

Form API

Tasks and Tabs Permissions

Variables

Database

Blocks Stylesheets JavaScript

Configuration

Reporting

Spam control Input validation

slide-8
SLIDE 8

The sources we use:

slide-9
SLIDE 9

Demo

slide-10
SLIDE 10

Tools & Resources

slide-11
SLIDE 11

Drupal Module Upgrader

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

slide-12
SLIDE 12

cd /My/Drupal8/root/ drush dl drupalmoduleupgrader cd modules/drupalmoduleupgrader composer install drush en drupalmoduleupgrader

Drupal Module Upgrader

Install to a Drupal 8 site:

slide-13
SLIDE 13

Create a report: Will create a report “upgrade-info.html ” in your module directory drush dmu-analyze MODULE_NAME

Drupal Module Upgrader

slide-14
SLIDE 14

Drupal Module Upgrader

slide-15
SLIDE 15

Change records for Drupal core

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

slide-16
SLIDE 16

Change records for Drupal core

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

slide-17
SLIDE 17

Learn some Symfony

slide-18
SLIDE 18

RTFM

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

slide-19
SLIDE 19

Try to convert the code:

Drupal Module Upgrader

drush dmu-upgrade MODULE_NAME

slide-20
SLIDE 20

Drupal 7: dmu-upgrade:

slide-21
SLIDE 21
slide-22
SLIDE 22

Drupal 7: After cleanup:

slide-23
SLIDE 23

The Steps To Take

slide-24
SLIDE 24

Module information

https://flic.kr/p/adF44b

slide-25
SLIDE 25

Module information

// helpfulness.info name = Helpfulness description = Provides a block for the user to leave feedback core = "7.x"

Drupal 7:

slide-26
SLIDE 26

Module information

// helpfulness.info.yml name: Helpfulness description: 'Provides a block for the user to leave feedback' core: 8.x type: module

Drupal 8:

slide-27
SLIDE 27

Menu and Routing

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

slide-28
SLIDE 28

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:

slide-29
SLIDE 29

Menu and Routing

# helpfulness.routing.yml helpfulness.report_form: path: /admin/reports/helpfulness defaults: _title: 'Helpfulness Feedback messages' _form: \Drupal\helpfulness\Form\HelpfulnessReportForm requirements: _permission: 'view helpfulness messages' # helpfulness.links.menu.yml helpfulness.report_form: route_name: helpfulness.report_form title: 'Helpfulness Feedback messages' description: 'View messages from the helpfulness module.' parent: system.admin_reports

Drupal 8:

slide-30
SLIDE 30

Permissions

slide-31
SLIDE 31

Permissions

// helpfulness.module function 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:

slide-32
SLIDE 32

Permissions

// helpfulness.permissions.yml 'view helpfulness messages': title: 'Access helpfulness feedback report' description: 'View and delete helpfulness messages.' # helpfulness.routing.yml helpfulness.report_form: path: /admin/reports/helpfulness defaults: _title: 'Helpfulness Feedback messages' _form: \Drupal\helpfulness\Form\HelpfulnessReportForm requirements: _permission: 'view helpfulness messages'

Drupal 8:

slide-33
SLIDE 33

Forms

slide-34
SLIDE 34

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:

slide-35
SLIDE 35

Forms

// helpfulness.routing.yml helpfulness.report_form: path: /admin/reports/helpfulness defaults: _title: 'Helpfulness Feedback messages' _form: \Drupal\helpfulness\Form\HelpfulnessReportForm // /src/Form/HelpfulnessReportForm.php namespace Drupal\helpfulness\Form; class HelpfulnessReportForm extends FormBase { public function buildForm(array $form, FormStateInterface $form_state){ /* …build the form... */ return $form; } }

Drupal 8:

slide-36
SLIDE 36

Database Table

https://flic.kr/p/puR46m

slide-37
SLIDE 37

// 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

slide-38
SLIDE 38

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:

slide-39
SLIDE 39

Thank you. Questions?

Heymo Vehse https://twitter.com/heymo https://www.drupal.org/u/heymo