future proof your drupal skills - piyuesh kumar

21
Future Proofing Your Drupal Skills Piyuesh Kumar QED42 1

Upload: drupal-camp-delhi

Post on 26-Jun-2015

1.651 views

Category:

Technology


1 download

TRANSCRIPT

Page 1: Future proof your drupal skills - Piyuesh Kumar

Future Proofing Your Drupal Skills

Piyuesh KumarQED42

1

Page 2: Future proof your drupal skills - Piyuesh Kumar

AGENDA:• Drupal 8 Api Changes:

•Module info file•Routing System•Drupal 8 CMI & Using Config inspector•Basic changes to oftenly uses Drupal functions.•Writing forms and their submit handlers in d8

• Live Demo of Porting a Drupal 7 module to Drupal 8.

2

Page 3: Future proof your drupal skills - Piyuesh Kumar

Info File•Info files changed to info.yml•Old info file: {d7.info}

•New info file: {d8.info.yml}

3

Page 4: Future proof your drupal skills - Piyuesh Kumar

Warning:Things are about to get...

geeky.

4

Page 5: Future proof your drupal skills - Piyuesh Kumar

ROUTING SYSTEM

• d7(hook_menu):

5

Page 6: Future proof your drupal skills - Piyuesh Kumar

D8 ROUTING SYSTEM(HOOK_MENU)

• d8 conversion(hook_menu):• Hook_menu Lives..:)

6

Page 7: Future proof your drupal skills - Piyuesh Kumar

D8 ROUTING SYSTEM(ROUTING.YML)

• d8 conversion:• Callbacks and permissions are defined in a yml

file.{d8.routing.yml}

7

Page 8: Future proof your drupal skills - Piyuesh Kumar

D8 ROUTING SYSTEM(WRITING CONTROLLERS)

• d8 conversion:• Writing Page Callbacks

8

Page 9: Future proof your drupal skills - Piyuesh Kumar

D8 ROUTING SYSTEM(CORE CONTROLLERS)

• _form• _content• _controller• _entity_form• _entity_list• and many more..

9

Page 10: Future proof your drupal skills - Piyuesh Kumar

CONFIGURATION SCHEMA

• R.I.P variable-get/variable_set

10

Page 11: Future proof your drupal skills - Piyuesh Kumar

CONFIGURATION SCHEMA

•When would Config data get saved?

• UI changes (automatic): When the save button is clicked on an admin page, data gets written to the active store as well as db.

• Code changes (manual): use admin/config/development/sync to sync the config in code with db and active store.

11

Page 12: Future proof your drupal skills - Piyuesh Kumar

CMI(EXAMPLE)

•D7:

•D8:

12

Page 13: Future proof your drupal skills - Piyuesh Kumar

USING CONFIG INSPECTOR

• https://drupal.org/project/config_inspector/git-instructions

13

Page 14: Future proof your drupal skills - Piyuesh Kumar

WRITING FORMS AND THEIR SUBMIT HANDLERS IN D8

•FormInterface(https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!FormInterface.php/interface/FormInterface/8)

•SystemConfigFormBase(http://drupalcontrib.org/api/drupal/drupal!core!modules!system!lib!Drupal!system!SystemConfigFormBase.php/class/SystemConfigFormBase/8)

14

Page 15: Future proof your drupal skills - Piyuesh Kumar

EXAMPLE

• D7:

15

Page 16: Future proof your drupal skills - Piyuesh Kumar

EXAMPLE• D8:

16

Page 17: Future proof your drupal skills - Piyuesh Kumar

D8 FORMS(VALIDATION & SUBMISSION)

•function validateForm(array &$form, array &$form_state) {}

•function submitForm(array &$form, array &$form_state) {}

17

Page 18: Future proof your drupal skills - Piyuesh Kumar

D8 FORMS(SYSTEM_SETTINGS_FORM

??)• Extends SystemConfigFormBase:

18

Page 19: Future proof your drupal skills - Piyuesh Kumar

D8 FORMS(OTHER EXTENDABLE CLASSES IN CORE)

• ConfirmFormBase(https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Form!ConfirmFormBase.php/class/ConfirmFormBase/8)

• BulkFormBase(https://api.drupal.org/api/drupal/core!modules!system!lib!Drupal!system!Plugin!views!field!BulkFormBase.php/8)

• FieldInstanceFormBase

• ViewsFormBase(https://api.drupal.org/api/drupal/core!modules!views_ui!lib!Drupal!views_ui!Form!Ajax!ViewsFormBase.php/class/ViewsFormBase/8)

19

Page 20: Future proof your drupal skills - Piyuesh Kumar

Basic Function from d7 to d8• hook_init removed(https://drupal.org/node/2013014)

• Module/hook system functions replaced with module handler service(https://drupal.org/node/1894902)

• drupal_goto has been removed(https://drupal.org/node/2023537)

• hook_boot has been removed(https://drupal.org/node/1909596)

• $_GET[‘q'] has been removed(https://drupal.org/node/1659562)

• For more goto https://drupal.org/list-changes

20

Page 21: Future proof your drupal skills - Piyuesh Kumar

21