Module Development

Implement a Block Plugin for Drupal 8, 9, and 10

Implementing plugins is a common task for Drupal developers. Often you'll need to add custom functionality using an existing plugin type--most likely an annotation-based plugin. This tutorial offers a structured approach to understanding and creating Drupal plugins, with a focus on annotation-based plugins.

In this tutorial, we'll:

  • Examine the custom block code we previously wrote, this time from the perspective of the Plugin API.
  • Introduce a recipe for creating annotation-based Drupal plugins.
  • Demonstrate how to find the necessary information for new plugin creation from existing plugins.

By the end of this tutorial, you will know how to examine the structure of existing plugin classes, so that you know how to implement a plugin of that type.

Drupal Module Developer Guide