Plug and Play with Plugins
Plugins power many items in Drupal, such as blocks, field types, and field formatters. Plugins and plugin types are provided by modules. They provide a swappable and specific functionality.
In this chapter, we will implement a block plugin. We will use the Plugin API to provide a custom field type along with a widget and formatter for the field. The last recipe will show you how to create and use a custom plugin type.
Upcoming changes to the plugin system in Drupal minor versions
PHP 8 provides a feature called PHP attributes (https://www.php.net/manual/en/language.attributes.overview.php). With Drupal 10’s adoption of PHP 8.1, there is consideration to adopt PHP attributes over code document annotations, which are used in this chapter.
Support for PHP attributes instead of annotations may be available in Drupal 10.1, the first minor release of Drupal 10. Annotations will be supported throughout Drupal 10 but may become deprecated. Deprecating...