Drupal 8 Deep Dive: Plugin System

  • Published on
    14-Jan-2015

  • View
    401

  • Download
    2

DESCRIPTION

Want to learn more about Acquias products, services, and happenings in the Drupal Community? Visit our site: http://bit.ly/yLaHO5. Drupal 8 has introduced a number of new (to Drupalists) technologies, but embedded in this mix are a handful of Drupal-centric innovations. Amongst the first of these to be introduced to Drupal 8 was the Plug-in system. The Plug-in system is a far reaching PHP Component that has largely replaced the old hook_info/alter pattern within Drupal and can be used outside of Drupal as well. In this webinar, Kris Vanderwater (You may know him as EclipseGc) will review: Examples of what appropriate plug-in system usages look like What plug-in tools exist and how to leverage them Where to get information on building your own plug-in types How to use the existing helper classes in Drupal for the greatest impact We will compare and contrast how Drupal 7 versus Drupal 8 works for plugin converted subsystems to frame the discussion around when and why to build a conversion. In addition to this we will dig into the tools and classes Drupal provides out of the box, and dissect a simple example plug-in type that you can use to build your own plug-ins types and better understand the plug-in system. Experience level: Advanced

Transcript

  • 1. Drupal 8: PluginsA visual and technical deep dive.!Twitter session tag: #d8plugins

2. Kris Vanderwater Developer Evangelist, Acquia! Drupal 8: Scotch Initiative Owner! Twitter: @eclipsegc! Co-Maintainer: Chaos Tools! Maintainer: Contextual Administration 3. Drupal 8 Plugins: Topics What is a Plugin? Why Plugins? Benefits of Plugins Foundational Concepts Implementing Plugins Creating your own Plugin Type 4. Thank YouHelior Colorado 5. What is a Plugin? 6. What is a Plugin?Heliors Definition: A discreet class thatexecutes an operation within thecontext of a given scope, as a meansto extend Drupals functionality.!!!!! 7. What is a Plugin?Heliors Definition: A discreet class thatexecutes an operation within thecontext of a given scope, as a meansto extend Drupals functionality.!!Kris Definition: A discoverable classthat implements a particular interfacewhich adds or extends functionality toa pluggable subsystem. 8. What is a Plugin? Discoverable 9. What is a Plugin? Discoverable! Object Oriented 10. What is a Plugin? Discoverable! Object Oriented! Interface Driven 11. What is a Plugin? Discoverable! Object Oriented! Interface Driven! Swappable 12. What is a Plugin? Discoverable! Object Oriented! Interface Driven! Swappable! Drupal not required 13. Why Plugins? 14. Why Plugins? Drupal actually is kinda unique 15. Why Plugins? Drupal actually is kinda unique! Unprecedented Configurability 16. Why Plugins? Drupal actually is kinda unique! Unprecedented Configurability! Absence of similar code 17. Why Plugins? Drupal actually is kinda unique! Unprecedented Configurability! Absence of similar code! Other CMS dont expose as much 18. Why Plugins? Drupal actually is kinda unique! Unprecedented Configurability! Absence of similar code! Other CMS dont expose as much! Frameworks expect it to be hard coded 19. Benefits of Plugins: 20. Benefits of Plugins: Definition & Implementation are co-located 21. Drupal 7 hook_block_info() 22. Drupal 7 hook_block_info() 23. Drupal 7 hook_block_view() 24. Drupal 7 hook_block_view() 25. Drupal 8 SystemPoweredByBlock 26. Benefits of Plugins: Definition & Implementation are co-located! Plugins are Object Oriented 27. Drupal 7 Block Hooks hook_block_info()! hook_block_info_alter()! hook_block_view()! hook_block_view_alter()! hook_block_view_MODULE_DELTA_alter()! hook_block_configure()! hook_block_save() 28. Drupal 8 BlockPluginInterface label()! access()! build()! blockForm()! blockValidate()! blockSubmit()! getMachineNameSuggestion()! getVisibilityConditions()! getVisibilityCondition()! setVisibilityConfig() 29. Methods not implemented by BlockBase label()! access()! build()! blockForm()! blockValidate()! blockSubmit()! getMachineNameSuggestion()! getVisibilityConditions()! getVisibilityCondition()! setVisibilityConfig() 30. Plugins are Extensible Inherit from base class! Inherit from other plugins 31. Drupal 8 SystemPoweredByBlock 32. Benefits of Plugins: Definition & Implementation are co-located! Plugins are Object Oriented! Plugins are Lazy Loaded by default 33. Drupal 7 Block Hooks hook_block_info()! hook_block_info_alter()! hook_block_view()! hook_block_view_alter()! hook_block_view_MODULE_DELTA_alter()! hook_block_configure()! hook_block_save() 34. Drupal 8 System Blocks!Contents of core/modules/system/src/Plugin/Block SystemBrandingBlock.php! SystemBreadcrumbBlock.php! SystemHelpBlock.php! SystemMainBlock.php! SystemMenuBlock.php! SystemPoweredByBlock.php 35. Benefits of Plugins: Definition & Implementation are co-located! Plugins are Object Oriented! Plugins are Lazy Loaded by default! Common Pattern (Learn once, use every where) 36. Drupal 8 Core Plugin Types Actions Archivers Blocks CKEditorPlugins Conditions Editors EntityReferenceSelectors Field Types Tool Tips Views Access Views Area Views ArgumentDefaults Views ArgumentValidators Views Cache Views Displays Views DisplayExtenders Views ExposedForms Field Formatters Field Widgets Filters Image Effects Mail Contextual Links Local Actions Local Tasks QuickeditEditors Search Views Fields Views Filters Views Joins Views Pagers Views Queries ViewsRelationships Views Rows Views Sorts Views Styles Views Wizards 37. Foundational Concepts: 38. Foundational Concepts: Autoloading 39. Foundational Concepts: Autoloading! PSR-0 & PSR-4 40. Autoloading Concepts: 41. Autoloading Concepts:PSR-0 DrupalCore => core/lib/Drupal/Core,! DrupalComponent => core/lib/Drupal/Component, 42. Autoloading Concepts:PSR-0 DrupalCore => core/lib/Drupal/Core,! DrupalComponent => core/lib/Drupal/Component,PSR-4 Drupalblock => core/modules/block/src, 43. Foundational Concepts: Autoloading! PSR-0 & PSR-4! Dependency Injection 44. Dependency Injection: 45. Foundational Concepts: Autoloading! PSR-0 & PSR-4! Dependency Injection! Service Containers 46. Service Containers: 47. Service Containers: 48. Service Containers: 49. Service Containers: 50. Service Containers: 51. Service Containers: 52. Service Containers: 53. Service Containers: 54. Service Containers: services.core.yml 55. Foundational Concepts: Autoloading! PSR-0 & PSR-4! Dependency Injection! Service Containers! Annotations 56. Annotations: @Block() 57. Annotations: Annotations are NOT CODE! 58. Annotations: Annotations are NOT CODE!! yaml, json, {insert_serializer} are NOT CODE! 59. Annotations: Annotations are NOT CODE!! yaml, json, {insert_serializer} are NOT CODE!! Annotations have more in common serialization. 60. Annotations: Annotations are NOT CODE!! yaml, json, {insert_serializer} are NOT CODE!! Annotations have more in common serialization.! Data not behavior. 61. To the Code!