The Drupal 8 plugin system: extensibility for all (Drupalaton 2015)

28
THE DRUPAL 8 PLUGIN SYSTEM: EXTENSIBILITY FOR ALL I am , , and . Xano @BartFeenstra http://mynameisbart.com

Transcript of The Drupal 8 plugin system: extensibility for all (Drupalaton 2015)

  1. 1. THE DRUPAL 8 PLUGIN SYSTEM: EXTENSIBILITY FOR ALL I am , , and .Xano @BartFeenstra http://mynameisbart.com
  2. 2. WHAT ARE PLUGINS? Swappable extensions that provide logic for a specific (set of) task(s) Uniquely identifiable Metadata Multiple instances can co-exist (reuse)
  3. 3. DRUPAL 7 PLUGINS Hook discovery (core and most contributed modules) File-based discovery (ctools) Magic hooks/callbacks/includes Some plugins are classed
  4. 4. SAY WHAT?
  5. 5. DRUPAL 8 PLUGINS Are classed. Always. Should implement interfaces. Consistent API for discovering and instantiating plugins, regardless of type.
  6. 6. NO MORE DARK MAGIC
  7. 7. JARGON, DO YOU SPEAK IT?
  8. 8. PLUGIN TYPE
  9. 9. PLUGIN (DEFINITION)
  10. 10. PLUGIN DISCOVERY
  11. 11. PLUGIN FACTORY
  12. 12. PLUGIN MANAGER (DISCOVERY + FACTORY + ...)
  13. 13. PLUGIN INSTANCE
  14. 14. PLUGIN CONFIGURATION
  15. 15. RECREATING/CLONING PLUGIN INSTANCES Using Plugin type/manager, ID, and configuration through ConfigurablePluginInterface.
  16. 16. DISCOVERY METHODS Annotated class discovery (mostly different logic) YAML discovery (mostly reused logic) Static discovery (testing) Hook discovery (deprecated)
  17. 17. ANNOTATED CLASS DISCOVERY
  18. 18. YAML DISCOVERY system.admin: title: Administration route_name: system.admin weight: 9 menu_name: admin system.admin_content: title: Content description: 'Find and manage content.' route_name: system.admin_content parent: system.admin weight: -10 system.admin_structure: route_name: system.admin_structure parent: system.admin description: 'Administer blocks, content types, menus, etc.' title: Structure weight: -8
  19. 19. FORMS
  20. 20. DERIVATIVES One base plugin definition can be dynamically expanded into multiple derivative plugin definitions.
  21. 21. THERE'S A MODULE FOR THAT http://drupal.org/project/plugin
  22. 22. PLUGIN TYPE DISCOVERY
  23. 23. ADMINISTRATIVE OVERVIEW
  24. 24. CONFIGURATION SCHEMAS plugin.plugin_configuration.*.*
  25. 25. TYPED PLUGIN DEFINITION API Now: PluginDefinitionMapperInterface Future: PluginDefinitionInterface
  26. 26. PLUGIN SELECTORS
  27. 27. FIELD TYPES/WIDGETS/FORMATTER S
  28. 28. CONCLUSION EXTENDING DRUPAL HAS NEVER BEEN EASIER. Review this presentation at .http://slideshare.net/bartfeenstra Find the Plugin module at .http://drupal.org/project/plugin I am , , and .Xano @BartFeenstra http://mynameisbart.com DO YOU HAVE ANY QUESTIONS? subsetsum @ Flickr (CC BY-NC-ND 2.0)