Drupal 8 plugin system
aspilicious!
About me
•  Bram Goffings
@aspilicious
•  Drupal developer
•  Work for Nascom
www.nascom.be
•  Maintainer of Display Suite
•  Drupal 8 core contributor
Target audience
•  Site builders & module developers
•  Experience with module development
•  Understanding of the hook system
•  Know how to handle object oriented code
Success?
•  Nobody is scared anymore
•  Everyone can make a *basic* plugin type
Not the expert
•  I’m an end user, just like you
•  Learned by trying (and failing)
•  I can say stupid things
Drupal developer
•  Mr. Steven
•  Brave drupal 7 expert
•  Made his first Drupal 8 site
•  Wants to build a plugin
system
Client
•  Mr. Arnold
•  Rich webmaster
•  Loves cars
•  I want to choose my favorite car on my profile from
a predefined list.
•  It should be possible to plug in different cars into
the list.
•  The name and an image of the selected car should
placed on the homepage.
I take the job…
Step 1
I want to choose my favorite car on my profile
from a predefined list.
Arnold’s wireframe
Steven’s plan
•  Add a “Car selector” field
•  Create a custom select widget
The drupal 7 way
•  Implements hook_field_widget_info()
•  Implements hook_field_widget_form()
Those hooks are gone!
They are plugin-y-fied!
What is a plugin?
Plugins are small pieces of functionality that are
swappable.
Plugins that perform similar functionality are of the
same plugin type.
Field widget plugins!
•  There is a “widget” plugin type!
•  Each field widget is from that type!
Structure
SelectWidget.php
namespace DrupaloptionsPluginFieldFieldWidget;
SelectWidget.php
namespace DrupaloptionsPluginFieldFieldWidget;
SelectWidget.php
namespace DrupaloptionsPluginFieldFieldWidget;
SelectWidget.php
namespace DrupaloptionsPluginFieldFieldWidget;
Namespaces
•  Namespaces were introduced in PHP 5.3
•  Used to avoid name collisions
PSR-0
•  Aims to provide a standard file, class and namespace
convention to allow plug-and-play code.
•  Uses the defined namespaces to automatically load files when
needed.
•  One on one mapping between namespaces and directory
structure.
SelectWidget.php
namespace DrupaloptionsPluginFieldFieldWidget;
Structure
PSR-4
•  “New standard”
•  Makes alternative mapping possible
•  Drupal will use it to remove “unneeded” folders. The empty
*drupal* and *module-name* folder won’t be needed
anymore.
Let’s recap
•  We know how to find plugins
•  We understand namespaces and the directory
structure
•  We understand PSR-0 and the difference between
PSR-4
SelectWidget.php
Available methods
Car module structure
car.info.yml
Dev days Szeged 2014: Plugin system in drupal 8
Step 1: done
Dev days Szeged 2014: Plugin system in drupal 8
Let’s recap
•  We know how to start with writing a field widget
plugin
•  We know how to start writing a custom module
Step 2
It should be possible to plug in
different cars into the list.
Steven’s plan
•  Create a custom plugin type named “Car”
•  Create two sample car plugins
Custom plugin type
•  Create a plugin manager service record
•  Create an annotation class
•  Create the plugin manager class
Custom plugin type
car.services.yml
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
Car module structure
(part 2)
Sample plugins
Sample plugins
getOptions() v2
Debug output
Car module structure
(part 3)
Let’s recap
•  We know how to write a basic plugin manager
•  We know how to handle annotations
•  We know how to get all the plugin definitions
Disadvantage
Each car requires a plugin
Derivative
•  Allows you to create multiple plugin definitions
through a single plugin class.
Derivative example!
•  Create a yml file containing cars!
•  Create a derivative plugin!
•  Create a definition for each car in the yml file!
cars-example.yml
YamlCar.php
Dev days Szeged 2014: Plugin system in drupal 8
Step 2: done
Dev days Szeged 2014: Plugin system in drupal 8
Let’s recap
•  We know when to use derivatives
•  We are able to build one
Step 3
The name and an image of the selected car should
placed on the homepage.
Steven’s plan
•  Add a function to the plugins that returns an image
url
•  Create the frontpage
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
hook_menu is gone!
car.routing.yml
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
Dev days Szeged 2014: Plugin system in drupal 8
Car module structure
(part 4)
Let’s recap
•  We figured out how to add a function to a plugin
•  We know how to create a plugin instance
•  We saw how we should create our routes
•  We learned how to build a page controller
The end
Questions?
THANK YOU!

More Related Content

PDF
[UniteKorea2013] 2D content workflows
PPTX
Custom Fields in Joomla - JoomlaDay UK 2016 - Marco Dings
PDF
A Gentle Introduction to GoOnRails
PDF
This is presentation at Mitaka.rb #10.
PPTX
PPTX
Creating Customizable Widgets for Unpredictable Needs
PPTX
React Native for ReactJS Devs
PDF
Introduction to React Native
[UniteKorea2013] 2D content workflows
Custom Fields in Joomla - JoomlaDay UK 2016 - Marco Dings
A Gentle Introduction to GoOnRails
This is presentation at Mitaka.rb #10.
Creating Customizable Widgets for Unpredictable Needs
React Native for ReactJS Devs
Introduction to React Native

What's hot (17)

PPTX
Native Script by Sebastian Witalec
PDF
Angular ❤️CMS
PPTX
The Way to Theme Enlightenment
PPTX
Dynamic content with Angular
KEY
The Architect Way
PPTX
Shortcodes vs Widgets: Which one and how?
PDF
Building a dynamic SPA website with Angular
PDF
FuelPHP presentation - PeoplePerHour workshop
PPTX
Developing Complex WordPress Sites without Fear of Failure (with MVC)
PPTX
coLearning PHP
PPTX
Laravel 5
PDF
Plone 5 theming
PPTX
PDF
An Introduction to ReactNative
PDF
FuelPHP - a PHP HMVC Framework by silicongulf.com
PPTX
Automation in Drupal
PDF
Alchemy CMS Präsentation Rails UG HH 09.2011
Native Script by Sebastian Witalec
Angular ❤️CMS
The Way to Theme Enlightenment
Dynamic content with Angular
The Architect Way
Shortcodes vs Widgets: Which one and how?
Building a dynamic SPA website with Angular
FuelPHP presentation - PeoplePerHour workshop
Developing Complex WordPress Sites without Fear of Failure (with MVC)
coLearning PHP
Laravel 5
Plone 5 theming
An Introduction to ReactNative
FuelPHP - a PHP HMVC Framework by silicongulf.com
Automation in Drupal
Alchemy CMS Präsentation Rails UG HH 09.2011
Ad

Similar to Dev days Szeged 2014: Plugin system in drupal 8 (20)

KEY
Intro to WordPress Plugins
PDF
Write your first WordPress plugin
PDF
Drupal 8 Deep Dive: Plugin System
 
PDF
Bending word press to your will
PPT
Making the Most of Plug-ins - WordCamp Toronto 2008
PDF
Test ss 2
ODP
Selecting A WordPress Plugin
PPTX
A peek into the world of WordPress plugin development
PPTX
Installing Plug-ins
PDF
How to Choose WordPress Plugins
PDF
Best Practices in Plugin Development (WordCamp Seattle)
PPT
WordPress plugins
PDF
Creating Extensible Plugins for WordPress
PPT
WordPress Plugin Development- Rich Media Institute Workshop
PDF
Extending WordPress - a guide to building your first plugin
ODP
WordPress Plugin Development For Beginners
PDF
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
 
PDF
Drupal 8 - Core and API Changes
PDF
Wordpress Plugin Development Practices
Intro to WordPress Plugins
Write your first WordPress plugin
Drupal 8 Deep Dive: Plugin System
 
Bending word press to your will
Making the Most of Plug-ins - WordCamp Toronto 2008
Test ss 2
Selecting A WordPress Plugin
A peek into the world of WordPress plugin development
Installing Plug-ins
How to Choose WordPress Plugins
Best Practices in Plugin Development (WordCamp Seattle)
WordPress plugins
Creating Extensible Plugins for WordPress
WordPress Plugin Development- Rich Media Institute Workshop
Extending WordPress - a guide to building your first plugin
WordPress Plugin Development For Beginners
Drupal 8, Where Did the Code Go? From Info Hook to Plugin
 
Drupal 8 - Core and API Changes
Wordpress Plugin Development Practices
Ad

Recently uploaded (20)

PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
Cybersecurity: Protecting the Digital World
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PDF
Time Tracking Features That Teams and Organizations Actually Need
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Cost to Outsource Software Development in 2025
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
iTop VPN Crack Latest Version Full Key 2025
PPTX
Introduction to Windows Operating System
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PPTX
CNN LeNet5 Architecture: Neural Networks
PDF
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
MCP Security Tutorial - Beginner to Advanced
PPTX
Tech Workshop Escape Room Tech Workshop
PDF
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
PDF
Wondershare Recoverit Full Crack New Version (Latest 2025)
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
GSA Content Generator Crack (2025 Latest)
Advanced SystemCare Ultimate Crack + Portable (2025)
Cybersecurity: Protecting the Digital World
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Time Tracking Features That Teams and Organizations Actually Need
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Cost to Outsource Software Development in 2025
DNT Brochure 2025 – ISV Solutions @ D365
How Tridens DevSecOps Ensures Compliance, Security, and Agility
iTop VPN Crack Latest Version Full Key 2025
Introduction to Windows Operating System
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
CNN LeNet5 Architecture: Neural Networks
How to Make Money in the Metaverse_ Top Strategies for Beginners.pdf
Why Generative AI is the Future of Content, Code & Creativity?
MCP Security Tutorial - Beginner to Advanced
Tech Workshop Escape Room Tech Workshop
Multiverse AI Review 2025: Access All TOP AI Model-Versions!
Wondershare Recoverit Full Crack New Version (Latest 2025)
Monitoring Stack: Grafana, Loki & Promtail
GSA Content Generator Crack (2025 Latest)

Dev days Szeged 2014: Plugin system in drupal 8