the drupal 8 plugin system: extensibility for all (drupalcamp baltics 2015)
Post on 13-Apr-2017
612 Views
Preview:
TRANSCRIPT
-
THE DRUPAL 8 PLUGINSYSTEM: EXTENSIBILITY FOR
ALLI am , , and .Xano @BartFeenstra http://mynameisbart.com
http://drupal.org/u/xanohttp://mynameisbart.com/http://twitter.com/bartfeenstra
-
WHAT ARE PLUGINS?Swappable extensions that provide logic for a specific (set of) task(s)Uniquely identifiableMetadataMultiple instances can co-exist (reuse)
-
DRUPAL 7 PLUGINSHook discovery (core and most contributed modules)File-based discovery (ctools)Magic hooks/callbacks/includesSome plugins are classed
-
SAY WHAT?
-
DRUPAL 8 PLUGINSAre classed. Always.Should implement interfaces.Consistent API for discovering and instantiating plugins, regardless oftype.
-
NO MORE DARK MAGIC
-
JARGON, DO YOU SPEAK IT?
-
PLUGIN TYPE
-
PLUGIN (DEFINITION)
-
PLUGIN DISCOVERY
-
PLUGIN FACTORY
-
PLUGIN MANAGER(DISCOVERY + FACTORY + ...)
-
PLUGIN INSTANCE
-
PLUGIN CONFIGURATION
-
RECREATING/CLONINGPLUGIN INSTANCES
Using Plugin type/manager, ID, and configuration throughConfigurablePluginInterface.
-
DISCOVERY METHODSAnnotated class discovery (mostly different logic)YAML discovery (mostly reused logic)Static discovery (testing)Hook discovery (deprecated)
-
ANNOTATED CLASSDISCOVERY
-
YAML DISCOVERY
system.admin: title: Administration route_name: system.admin weight: 9 menu_name: adminsystem.admin_content: title: Content description: 'Find and manage content.' route_name: system.admin_content parent: system.admin weight: -10system.admin_structure: route_name: system.admin_structure parent: system.admin description: 'Administer blocks, content types, menus, etc.' title: Structure weight: -8
-
FORMS
-
DERIVATIVESOne base plugin definition can be dynamically expanded into multiple
derivative plugin definitions.
-
THERE'S A MODULE FORTHAT
http://drupal.org/project/plugin
http://drupal.org/project/plugin
-
PLUGIN TYPE DISCOVERY
-
ADMINISTRATIVE OVERVIEW
-
CONFIGURATION SCHEMASplugin.plugin_configuration.*.*
-
TYPED PLUGIN DEFINITIONAPI
Now: PluginDefinitionMapperInterface
Future: PluginDefinitionInterface
-
PLUGIN SELECTORS
-
FIELDTYPES/WIDGETS/FORMATTER
S
-
CONCLUSIONEXTENDING 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)
http://twitter.com/bartfeenstrahttp://slideshare.net/bartfeenstrahttp://mynameisbart.com/http://drupal.org/u/xanohttp://drupal.org/project/plugin
top related