Plugins to the Rescue! Decouple Your Code Without Losing Sleep: DrupalCon Portland 2022

Speakers: Tony Savorelli and Hector Lopez Trejo

Have you ever wondered how to contribute to Drupal, but your logic is quite tied to your actual site? Are you a maintainer of a contrib module and you are looking to provide extension points to site devs or other contrib devs? Welcome to the world of plugins.

While hooks have been the main extension points for the most part of Drupal’s history, we can now use more modern and flexible methodologies to make our code extensible, such as plugins and event subscribers.

In this talk we will show our audience how to implement their own plugin systems, or use existing ones, and present a case study on how adopting plugins helped reduce code complexity and improve customization in a contributed module.

We will cover:
* Extension mechanisms for Drupal modules: hooks, events, plugins, service decoration, and their pros and cons.
* What are plugins in Drupal 8+?
* How to develop a simple plugin system.
* How to use a plugin system.
* When and how to implement a plugin.
* A real world example: how a lot of code for altering the Lingotek module behavior (a contrib module) for a concrete use case in a given site transitioned into an easier maintenance and lower code system via plugins and collaboration.

Drupal is a registered trademark of Dries Buytaert.