In Drupal 8 and Symfony, we use annotations as metadata; these appear to look as though they are comments, but we have some keywords that allow us to tell Drupal what the plugin is and what it does:
/** * Class DonateForm * @package Drupal\donate\Form * * @Block( * id = "donate_block", * admin_label = @Translation("Donation block"), * category = @Translation("Custom") * ) */
- id: This is our plugins, unique identifier.
- admin_label: This shows the title of the plugin.
- category: This shows which category our plugin is in.
The annotations are straightforward, but they are required for Drupal to know about the plugin.
We now need a method of build() that will then make our block. Inside this method, we want to locate the form_id ...