SlideShare a Scribd company logo
1 of 30
Drupal 8:
The Plugin System
Ajit Shinde
@azeets
AjitS
Sr. Drupal Developer
Piyuesh Kumar
@piyuesh23
Drupal Architect
• What are Plugins?
Benefits, why use them?
Existence in D7
Plugin Eco-system
Plugin Manager
Demo Plugin Manager
AGENDA
Something that provides a set of guidelines and
reusable code components to allow developers
to expose pluggable components within their
code and (as needed) support managing these
components through the user interface.
What is a Plugin?
Design-Pattern
A general reusable solution to a recurring
problem within a given context.
What actually is a Plugin?
• Discovery
Decorators
Factory
Mapper
Manager
TERMINOLOGIES
• Not tied with Drupal
Lazy loaded
Extensible because of the use of object oriented
programming concept : class
Interface driven
Does only one thing at a time
Swappable
Why Plugins / Benefits?
Plugin Types in Core
Field Formatters
Field Widgets
Filters
Image Effects
Mail
Contextual Links
Local Actions
Local Tasks
Quickedit
Editors
Search
Tool Tips
Views Access
Views Argument
Default
Views Argument
Defaults
Views Argument
Validators
Views cache
Views Display
Extenders
Actions
Archivers
Blocks
CKEditor
Plugins
Conditions
Editors
Entity
Reference
Selectors
Field Types
Actions
Archivers
Blocks
CKEditor
Plugins
Conditions
Editors
Entity
Reference
Selectors
Field Types
EXISTENCE IN DRUPAL7
• ctools module provided a way to define
plugins
• e.g. content type plugin, context plugin, etc.
PLUGIN ECOSYSTEM
DISCOVERY MANAGER
MAPPERS
DISCOVERY
DECORATORS
FACTORIES
PLUGINS
PLUGIN MANAGER
• Discovery
• Instantiation
• Functionality
• Grouping
PLUGIN MANAGER
PluginManagerBase
PluginManagerInterface
DiscoveryInterface FactoryInterface MapperInterface
Implements
Extends
PLUGIN MANAGER
• Extend DefaultPluginManager + use defaults
• Extend DefaultPluginManager
• Override DefaultPluginManager::discovery()
• Override DefaultPluginManager::factory()
OR
HELPER FUNCTIONS
• getDefinition/s()
• getDiscovery()
• getFactory()
• createInstance()
• getInstance()
PLUGIN DISCOVERY
• Annotated Plugin Discovery
• Hook Based Plugin Discovery
• YAML Based Plugin Discovery
• Static Plugin Discovery
ANNOTATED PLUGIN DISCOVERY
• Provided by AnnotatedClassDiscovery class
• Follows PSR-4 standard
• Metadata is read from the @docblock
MyPluginManager::discovery = new AnnotatedClassDiscovery(‘Plugin/Block’, $namespace
HOOK BASED PLUGIN DISCOVERY
• Provided by HookDiscovery class
• Discovery based on the info hooks as done in
Drupal 7
• Mainly present to provide backwards compatibility
• Eg. The following provides a
{module_name}_block_info in the module file
MyPluginManager::discovery = new HookDiscovery($this->moduleHandler, 'block_info');
YAML BASED PLUGIN DISCOVERY
• Provided by YamlDiscovery class
• Using the YML file located at the module root to
read the metadata
MyPluginManager::discovery = new YamlDiscovery('blocks',
$module_handler->getModuleDirectories());
E.g. mymodule.blocks.yml
block:
id: "block_id"
admin_label: "Label for user interface"
category: "Category of the block"
STATIC PLUGIN DISCOVERY
• Provided by StaticDiscovery class
• Manually register plugin definition
• Mainly used in tests
MyPluginManager::discovery = new StaticDiscovery();
Discovery Decorators
• Wrapper around discovery class
• The decorator wraps around a DiscoveryInterface to
provide additional functionality.
• E.g. For altering a the info given by the block and
defining a {mymodule}_block_info_alter
• Types:
• InfoHookDecorator
• Derivative Discovery Decorator
INFOHOOK DECORATOR
• Adds processing for plugins exposed via info hooks.
MyPluginManager::discovery = new InfoHookDecorator(
new HookDiscovery('block_info'), 'block_info_alter');
Discovery Decorators
• Provided by the DerivativeDiscoveryDecorator class
• Allows variable number of plugins based on
configuration or application state.
• Eg. Menu and the corresponding blocks
MyPluginManager::discovery = new DerivativeDiscoveryDecorator(
new HookDiscovery('block_info'));
PLUGIN FACTORIES
• Provides plugin manager with ::createInstance()
method
• Routes the request to the selected factory class
• Instantiates and returns the specific plugin instance
• Types:
• DefaultFactory
• ContainerFactory
• ReflectionFactory
DEFAULT FACTORY
• Basic factory defined as the DefaultFactory class
• Looks for the plugin class and arguments required,
instantiates the plugin and returns it
return new $plugin_class($configuration, $plugin_id, $plugin_definition);
CONTAINER FACTORY
• Extends the DefaultFactory class, with an additional
method ::create()
• Used to inject the service container, so that the
plugin could make use of it
• If service container is not passed, works as the
default factory.
return $plugin_class::create(Drupal::getContainer(), $configuration,
$plugin_id, $plugin_definition);
REFLECTION FACTORY
• Provided by the ReflectionFactory class.
• Provides a way to instantiate the by calling the
appropriate constructor with correct arguments.
• Provides an abstraction layer.
$arguments = $this->getInstanceArguments($reflector, $plugin_id,
$plugin_definition, $configuration);
$instance = $reflector->newInstanceArgs($arguments);
return $instance
PLUGIN MAPPERS
• Provide an additional layer of abstraction around
plugin factory.
• Allow extra processing before instantiating the
plugin
• Similar to the decorators in the plugin discovery.
• Eg. Cache objects with different caching
mechanisms, RESTFUL services.
TIME FOR SOME FUN
METAPHOR
THANK YOU!

More Related Content

Viewers also liked

Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...
Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...
Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...Azwaniey Ahmad
 
Presentació de Japó
Presentació de JapóPresentació de Japó
Presentació de Japóarnaufranques
 
Pets company
Pets companyPets company
Pets companykysjw24
 
Ch6 atomssection2
Ch6 atomssection2Ch6 atomssection2
Ch6 atomssection2cwyatt01
 
Ch4 densityandbuoyancysection2
Ch4 densityandbuoyancysection2Ch4 densityandbuoyancysection2
Ch4 densityandbuoyancysection2cwyatt01
 
New microsoft office power point 2007 presentation
New microsoft office power point 2007 presentationNew microsoft office power point 2007 presentation
New microsoft office power point 2007 presentationCarol Green
 
Ch12 speedsection3
Ch12 speedsection3Ch12 speedsection3
Ch12 speedsection3cwyatt01
 
Future Proofing Your Drupal Skills
Future Proofing Your Drupal SkillsFuture Proofing Your Drupal Skills
Future Proofing Your Drupal SkillsPiyuesh Kumar
 
20110322 oracle
20110322 oracle20110322 oracle
20110322 oracleKwonjs
 
Ch14 forceandmotionsection1
Ch14 forceandmotionsection1Ch14 forceandmotionsection1
Ch14 forceandmotionsection1cwyatt01
 
Tugas pokok dan fungsi penyuluh pertanian
Tugas pokok dan fungsi penyuluh pertanianTugas pokok dan fungsi penyuluh pertanian
Tugas pokok dan fungsi penyuluh pertanianAdry Nelson
 
Claims evidence and reasoning presentation
Claims evidence and reasoning presentationClaims evidence and reasoning presentation
Claims evidence and reasoning presentationcwyatt01
 
Marketing opérationnel
Marketing opérationnel Marketing opérationnel
Marketing opérationnel raouia mira
 

Viewers also liked (20)

Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...
Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...
Buah mengkudu atau nama saintifiknya ialah morinda citrifolia telah digunakan...
 
Into to drupal8
Into to drupal8Into to drupal8
Into to drupal8
 
Presentació de Japó
Presentació de JapóPresentació de Japó
Presentació de Japó
 
Pets company
Pets companyPets company
Pets company
 
Ch6 atomssection2
Ch6 atomssection2Ch6 atomssection2
Ch6 atomssection2
 
Drupal performance
Drupal performanceDrupal performance
Drupal performance
 
Ch4 densityandbuoyancysection2
Ch4 densityandbuoyancysection2Ch4 densityandbuoyancysection2
Ch4 densityandbuoyancysection2
 
New microsoft office power point 2007 presentation
New microsoft office power point 2007 presentationNew microsoft office power point 2007 presentation
New microsoft office power point 2007 presentation
 
Ch12 speedsection3
Ch12 speedsection3Ch12 speedsection3
Ch12 speedsection3
 
Herba
HerbaHerba
Herba
 
Future Proofing Your Drupal Skills
Future Proofing Your Drupal SkillsFuture Proofing Your Drupal Skills
Future Proofing Your Drupal Skills
 
Dcm migration
Dcm migrationDcm migration
Dcm migration
 
20110322 oracle
20110322 oracle20110322 oracle
20110322 oracle
 
Ch14 forceandmotionsection1
Ch14 forceandmotionsection1Ch14 forceandmotionsection1
Ch14 forceandmotionsection1
 
Ibm
IbmIbm
Ibm
 
Dcp'14 drush
Dcp'14 drushDcp'14 drush
Dcp'14 drush
 
CSPS Test
CSPS TestCSPS Test
CSPS Test
 
Tugas pokok dan fungsi penyuluh pertanian
Tugas pokok dan fungsi penyuluh pertanianTugas pokok dan fungsi penyuluh pertanian
Tugas pokok dan fungsi penyuluh pertanian
 
Claims evidence and reasoning presentation
Claims evidence and reasoning presentationClaims evidence and reasoning presentation
Claims evidence and reasoning presentation
 
Marketing opérationnel
Marketing opérationnel Marketing opérationnel
Marketing opérationnel
 

Similar to Dcp'15

Building modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf FildebrandtBuilding modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf Fildebrandtmfrancis
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxanguraju1
 
Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Pei-Hsuan Hsieh
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)stanbridge
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Oscar Merida
 
Modular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireModular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireJeff Fox
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptxSachin Patidar
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#Daniel Fisher
 
Using DITAworks for Eclipse Help publishing
Using DITAworks for Eclipse Help publishingUsing DITAworks for Eclipse Help publishing
Using DITAworks for Eclipse Help publishingwild_wild_leha
 
Webcenter Sites Google Gadget Development Techniques
Webcenter Sites Google Gadget Development TechniquesWebcenter Sites Google Gadget Development Techniques
Webcenter Sites Google Gadget Development TechniquesJohn Brunswick
 
Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)Antonio Peric-Mazar
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013DuckMa
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with RailsPaul Gallagher
 
Oscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionOscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionPatrick Chanezon
 
CUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsCUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsAlfresco Software
 

Similar to Dcp'15 (20)

Building modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf FildebrandtBuilding modular software with OSGi - Ulf Fildebrandt
Building modular software with OSGi - Ulf Fildebrandt
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development Eclipse IDE, 2019.09, Java Development
Eclipse IDE, 2019.09, Java Development
 
Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)Cs 1023 lec 8 design pattern (week 2)
Cs 1023 lec 8 design pattern (week 2)
 
Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)Staying Sane with Drupal (A Develper's Survival Guide)
Staying Sane with Drupal (A Develper's Survival Guide)
 
Modular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireModular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter Bonfire
 
Eclipse UI automation
Eclipse UI automationEclipse UI automation
Eclipse UI automation
 
Creational Design Patterns.pptx
Creational Design Patterns.pptxCreational Design Patterns.pptx
Creational Design Patterns.pptx
 
2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#2009 Dotnet Information Day: More effective c#
2009 Dotnet Information Day: More effective c#
 
Using DITAworks for Eclipse Help publishing
Using DITAworks for Eclipse Help publishingUsing DITAworks for Eclipse Help publishing
Using DITAworks for Eclipse Help publishing
 
Webcenter Sites Google Gadget Development Techniques
Webcenter Sites Google Gadget Development TechniquesWebcenter Sites Google Gadget Development Techniques
Webcenter Sites Google Gadget Development Techniques
 
Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)Drupal8 for Symfony Developers (PHP Day Verona 2017)
Drupal8 for Symfony Developers (PHP Day Verona 2017)
 
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
Matteo Gazzurelli - Andorid introduction - Google Dev Fest 2013
 
Advance RCP
Advance RCPAdvance RCP
Advance RCP
 
Multi-tenancy with Rails
Multi-tenancy with RailsMulti-tenancy with Rails
Multi-tenancy with Rails
 
Oscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to ProductionOscon London 2016 - Docker from Development to Production
Oscon London 2016 - Docker from Development to Production
 
Apache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI ToolboxApache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI Toolbox
 
Apache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolboxApache DeltaSpike the CDI toolbox
Apache DeltaSpike the CDI toolbox
 
Extending Zend_Tool
Extending Zend_ToolExtending Zend_Tool
Extending Zend_Tool
 
CUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension PointsCUST-1 Share Document Library Extension Points
CUST-1 Share Document Library Extension Points
 

Recently uploaded

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 

Recently uploaded (20)

Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 

Dcp'15

  • 2. Ajit Shinde @azeets AjitS Sr. Drupal Developer Piyuesh Kumar @piyuesh23 Drupal Architect
  • 3. • What are Plugins? Benefits, why use them? Existence in D7 Plugin Eco-system Plugin Manager Demo Plugin Manager AGENDA
  • 4. Something that provides a set of guidelines and reusable code components to allow developers to expose pluggable components within their code and (as needed) support managing these components through the user interface. What is a Plugin?
  • 5. Design-Pattern A general reusable solution to a recurring problem within a given context. What actually is a Plugin?
  • 7. • Not tied with Drupal Lazy loaded Extensible because of the use of object oriented programming concept : class Interface driven Does only one thing at a time Swappable Why Plugins / Benefits?
  • 8. Plugin Types in Core Field Formatters Field Widgets Filters Image Effects Mail Contextual Links Local Actions Local Tasks Quickedit Editors Search Tool Tips Views Access Views Argument Default Views Argument Defaults Views Argument Validators Views cache Views Display Extenders Actions Archivers Blocks CKEditor Plugins Conditions Editors Entity Reference Selectors Field Types Actions Archivers Blocks CKEditor Plugins Conditions Editors Entity Reference Selectors Field Types
  • 9. EXISTENCE IN DRUPAL7 • ctools module provided a way to define plugins • e.g. content type plugin, context plugin, etc.
  • 11. PLUGIN MANAGER • Discovery • Instantiation • Functionality • Grouping
  • 13. PLUGIN MANAGER • Extend DefaultPluginManager + use defaults • Extend DefaultPluginManager • Override DefaultPluginManager::discovery() • Override DefaultPluginManager::factory() OR
  • 14. HELPER FUNCTIONS • getDefinition/s() • getDiscovery() • getFactory() • createInstance() • getInstance()
  • 15. PLUGIN DISCOVERY • Annotated Plugin Discovery • Hook Based Plugin Discovery • YAML Based Plugin Discovery • Static Plugin Discovery
  • 16. ANNOTATED PLUGIN DISCOVERY • Provided by AnnotatedClassDiscovery class • Follows PSR-4 standard • Metadata is read from the @docblock MyPluginManager::discovery = new AnnotatedClassDiscovery(‘Plugin/Block’, $namespace
  • 17. HOOK BASED PLUGIN DISCOVERY • Provided by HookDiscovery class • Discovery based on the info hooks as done in Drupal 7 • Mainly present to provide backwards compatibility • Eg. The following provides a {module_name}_block_info in the module file MyPluginManager::discovery = new HookDiscovery($this->moduleHandler, 'block_info');
  • 18. YAML BASED PLUGIN DISCOVERY • Provided by YamlDiscovery class • Using the YML file located at the module root to read the metadata MyPluginManager::discovery = new YamlDiscovery('blocks', $module_handler->getModuleDirectories()); E.g. mymodule.blocks.yml block: id: "block_id" admin_label: "Label for user interface" category: "Category of the block"
  • 19. STATIC PLUGIN DISCOVERY • Provided by StaticDiscovery class • Manually register plugin definition • Mainly used in tests MyPluginManager::discovery = new StaticDiscovery();
  • 20. Discovery Decorators • Wrapper around discovery class • The decorator wraps around a DiscoveryInterface to provide additional functionality. • E.g. For altering a the info given by the block and defining a {mymodule}_block_info_alter • Types: • InfoHookDecorator • Derivative Discovery Decorator
  • 21. INFOHOOK DECORATOR • Adds processing for plugins exposed via info hooks. MyPluginManager::discovery = new InfoHookDecorator( new HookDiscovery('block_info'), 'block_info_alter');
  • 22. Discovery Decorators • Provided by the DerivativeDiscoveryDecorator class • Allows variable number of plugins based on configuration or application state. • Eg. Menu and the corresponding blocks MyPluginManager::discovery = new DerivativeDiscoveryDecorator( new HookDiscovery('block_info'));
  • 23. PLUGIN FACTORIES • Provides plugin manager with ::createInstance() method • Routes the request to the selected factory class • Instantiates and returns the specific plugin instance • Types: • DefaultFactory • ContainerFactory • ReflectionFactory
  • 24. DEFAULT FACTORY • Basic factory defined as the DefaultFactory class • Looks for the plugin class and arguments required, instantiates the plugin and returns it return new $plugin_class($configuration, $plugin_id, $plugin_definition);
  • 25. CONTAINER FACTORY • Extends the DefaultFactory class, with an additional method ::create() • Used to inject the service container, so that the plugin could make use of it • If service container is not passed, works as the default factory. return $plugin_class::create(Drupal::getContainer(), $configuration, $plugin_id, $plugin_definition);
  • 26. REFLECTION FACTORY • Provided by the ReflectionFactory class. • Provides a way to instantiate the by calling the appropriate constructor with correct arguments. • Provides an abstraction layer. $arguments = $this->getInstanceArguments($reflector, $plugin_id, $plugin_definition, $configuration); $instance = $reflector->newInstanceArgs($arguments); return $instance
  • 27. PLUGIN MAPPERS • Provide an additional layer of abstraction around plugin factory. • Allow extra processing before instantiating the plugin • Similar to the decorators in the plugin discovery. • Eg. Cache objects with different caching mechanisms, RESTFUL services.