In Drupal, a block is a piece of content that can be placed in a region provided by a theme. Blocks are used to present specific kinds of content, such as a user login form, a snippet of text, and many more.
Blocks are annotated plugins. Annotated plugins use documentation blocks to provide details of the plugin. They are discovered in the module's Plugin
class namespace. Each class in the Plugin/Block
namespace will be discovered by the Block module's plugin manager.
In this recipe, we will define a block that will display a copyright snippet and the current year and place it in the footer region.
Create a new module like the one shown in this recipe, with a defined info.yml
so that it can be discovered by Drupal. We will refer to the module as mymodule
throughout the recipe. Use your module's appropriate name.