Slide 1

Slide 1 text

Drupal 8 Module Workshop Adam Malone Josh Li

Slide 2

Slide 2 text

Benefits / why ● https://drupal.org/node/2136029 ● Uptake of 8.x will be stalled without contrib ● Starting now will put you ahead of the curve

Slide 3

Slide 3 text

What happened with 7.x? 7.x core 7.x views A: Release of Drupal 7.0 B: Release of Views 7.3-rc1

Slide 4

Slide 4 text

Who else is becoming 8.x ready? ● Views (in core) ● devel(+kint) ● Webform ● Rules ● Many more ● Adam & Josh

Slide 5

Slide 5 text

How to start porting ● Start small - find a simple module ○ select modules you’ve used ○ < 15000 characters ● Create your own ● Follow examples ○ pants.module ○ example.module ○ and any core modules

Slide 6

Slide 6 text

Where to start architecturally ● .info files are now yaml ● menu routing is now yaml ● variable system is gone (config is now yaml) ● admin forms work differently (class per form) ● The rest of the .module may be fairly similar

Slide 7

Slide 7 text

Drupémon

Slide 8

Slide 8 text

CMI ● Replacement for variable_* ● Exportable ○ defaults => yaml ○ active => db ○ staging => files can be imported into active user.flood.yml user.mail.yml user.role.anonymous.yml user.role.authenticated.yml user.settings.yml $conf = \Drupal::config('user.flood'); uid_only: false ip_limit: 50 ip_window: 3600 user_limit: 5 user_window: 21600 $conf->get(‘user_limit’); 5 $conf->set(‘user_limit’, 1); $conf->save();

Slide 9

Slide 9 text

Routing ● foo.routing.yml ● foo.menu_links.yml ● foo.local_actions.yml ● foo.local_tasks.yml

Slide 10

Slide 10 text

foo.menu_links.yml

Slide 11

Slide 11 text

foo.local_actions.yml

Slide 12

Slide 12 text

foo.local_tasks.yml

Slide 13

Slide 13 text

How to alter menu paths in 8.x ● hook_menu_link_defaults_alter ● hook_menu_local_tasks_alter ● hook_menu_local_actions_alter

Slide 14

Slide 14 text

Forms ● Extend base classes ○ ContentEntityForm ○ ContentEntityConfirmFormBase ● form api is the same ● Inject classes

Slide 15

Slide 15 text

Chasing HEAD ● For contrib work, use the latest release (alpha/beta/rc) ● Assume HEAD will break your code ● IDEs can help you with deprecations ● Change notices are usually great to peruse