everything you ever wanted to know about drupal 8
play

Everything you ever wanted to know about Drupal 8* but were too - PowerPoint PPT Presentation

Everything you ever wanted to know about Drupal 8* but were too afraid to ask *conditions apply So you want to start a pony stud small horses, big hearts Drupal 8 - in a nutshell Learn Once - Apply Everywhere* Source:


  1. Everything you ever wanted to know about Drupal 8* but were too afraid to ask *conditions apply

  2. So you want to start a pony stud small horses, big hearts

  3. Drupal 8 - in a nutshell Learn Once - Apply Everywhere* Source: http://www.sxc.hu/photo/784108 *Including outside Drupal

  4. Major Architectural Changes http://www.sxc.hu/photo/207618

  5. Don’t be afraid...

  6. "If you learnt php from Drupal - Drupal 8 will teach you modern php from a familiar setting" - Me, 2014

  7. Proudly invented elsewhere Installed with Composer: ● easyrdf/easyrdf ● symfony2/{various} ● symfony-cmf/routing ● zendframework/zend-feed ● guzzle/http ● doctrine/annotations ● ...

  8. Modern PHP ● PHP 5.4+ ● Object-oriented PHP ● Classes, Interfaces, Namespaces ● PSR-0, PSR-4

  9. Object-Oriented PHP Example menu_block/lib/Drupal/menu_block/MenuBlockRepository.php

  10. Dependency Injection http://www.sxc.hu/photo/778753

  11. Dependency Injection page_example/lib/Drupal/page_example/ExampleService.php

  12. Dependency Injection Container Symfony2 component Steps: 1. Write a class 2. Define it as a service in *.services.yml

  13. Dependency Injection Container page_example/page_examples.services.yml

  14. Extension points Plugins Modules Services

  15. Routing Pages and Forms http://pixabay.com/en/road-sign-arrows-arrow-direction-64060/

  16. Routing Pages and Forms What does D7 hook_menu really do? ● routes ● default menu items ● local actions ● local tasks

  17. D7 Hook Menu

  18. D7 Hook Menu

  19. Routing Pages 2 easy steps: 1. create a PHP class that extends ControllerBase 2. create route definition in module_name . routing.yml

  20. 2. Create a Controller class page_example/lib/Drupal/page_example/Controller/PageExampleController. php

  21. 1. Create a route definition page_example/page_example.routing.yml

  22. ControllerBase Goodies D7 D8 t(‘some text’) $this->t(‘some text’); l(‘title’, $path) $this->l(‘title’, $route_name); url($path) $this->url($route_name); drupal_goto($path) $this->redirect($route_name); global $user $this->currentUser(); variable_get($key) $this->config(‘group’)->get($key); cache_get($key) $this->cache()->get($key); module_exists($m) $this->moduleHandler()->moduleExists ($m)

  23. Controller DI Factory Pattern

  24. Routing Forms 2 steps: 1. create a form class that extends FormBase 2. create route definition in module .routing.yml

  25. Form Example

  26. Form Example

  27. What happened to hook_menu()? (sad face)

  28. Default Menu Links hook_menu_link_defaults()

  29. Local Actions module .local_actions.yml

  30. Local Tasks module .local_tasks.yml

  31. Other formats? Leveraging request accept headers ● Ajax controller ● Dialog controller ● REST Request uri Accept header Response node/1 application/hal+json The node in hal+json node/1 text/html The node page node/1 application/vnd.drupal-modal The node in a modal

  32. Routing Documentation https://drupal.org/node/2122071

  33. Configuration System http://www.sxc.hu/photo/425946

  34. Configuration System variable_{get,set} are gone! Config is stored in yaml files sites/default/files/config_{hash}/{active,staging}

  35. Configuration System $config = \Drupal::config('forum.settings'); $vocabulary = $config->get('vocabulary'); $config->set('vocabulary', 'hooha')->save(); In OO code, inject the @config.factory service

  36. Configuration System system_settings_form() is gone Instead subclass ConfigFormBase Example: @see \Drupal\system\Form\SiteInformationForm

  37. Configuration System Ctools exportables => Config Entities

  38. Configuration System Unified Entity API including config $node_type = $storage_controller->create($values); $node_type->save(); $node_type->label(); $node_type->id();

  39. Configuration System Module config imported on install Docs https://drupal.org/node/1667894

  40. Configuration System Deployment workflows Active => Staging => Active

  41. Configuration System Translatable in core Schemas for validation

  42. Configuration System State (Key/Value) API Settings API

  43. Plugins

  44. Plugins Learn plugins once - apply it everywhere

  45. Plugins Semi-random magic collection of hooks Real objects and interfaces

  46. Drupal 7 Block function forum_block_info() function forum_block_save() function forum_block_configure() function forum_block_view()

  47. Drupal 8 Block Steps: 1. Create a new PHP class 2. Add some annotations

  48. Blocks

  49. Plugins Advantages: ● Base classes ● Inheritance ● One file per plugin ● Nice. Neat. Tidy.

  50. Plugins So many more Learn Once Apply Everywhere More: http://bit.ly/1a50ygs *Stream wrappers still pending Image created with taxedo.com

  51. Migrate in core Sunday 10:30am chx

  52. Entities and Fields http://www.sxc.hu/photo/1433343

  53. Entities and Fields First class objects Swappable classes Common API No more of this crap $node->field_foo[LANGUAGE_NONE][0]['value']

  54. Entities and Fields New field types ● Link ● Email ● Comment ● Date ● Entity Reference ● Telephone

  55. Entities and Fields Display and form modes Base field consistency Fieldable blocks

  56. Entities and Fields Now plugins: ● Field types ● Field formatters ● Widgets

  57. Entities and Fields Unified API using first-class objects. D7 : $node->field_foo[LANGUAGE_NONE][0]['value'] D8: Node->title->value Node->field_foo->value

  58. Entities and Fields Info Discovery API $entity->getPropertyDefinitions() $entity->field_foobar->getFieldDefinition() @see Drupal\Core\Field\FieldDefinitionInterface

  59. Frontend http://twig.sensiolabs.org/

  60. Twig node.tpl.php -> node.html.twig Simple Safe

  61. Twig example

  62. There’s a session for that... “Can I TWIG It? Yes, You Can!” Sunday 11:30am mortendk

  63. theme() is deprecated Instead: Return render arrays with a #theme item

  64. #theme example

  65. drupal_add_js/css() removed No Javascript will be loaded by default Steps: 1. Declare assets with hook_library_info() 2. #attach your library in a render array

  66. Library Info Hook

  67. Coming soon... https://drupal.org/node/1996238

  68. #attached

  69. Responsive? Responsive core themes Responsive admin theme Picture element HTML5

  70. More JS Libraries in Core jQuery UI Touch Punch Backbone, Underscore modernizr domReady html5shiv & classList

  71. What else? Wysiwyg Plugins Tour Edit Backbone, Underscore Toolbar

  72. A Tour Of The Tour Module Sunday 1:30pm nick_schuch

  73. Current State DX Cleanup Criticals and beta blockers

  74. Current State

  75. Questions? Lee Rowlands Kim Pepper Senior Drupal Developer Technical Director PreviousNext PreviousNext @larowlan @kim.pepper @kimb0oo

Recommend


More recommend