Our first block plugin

So, this is our plugin class--HelloWorldSalutationBlock--that does just that:

namespace Drupal\hello_world\Plugin\Block;use Drupal\Core\Block\BlockBase;use Drupal\Core\Plugin\ContainerFactoryPluginInterface;use Symfony\Component\DependencyInjection\ContainerInterface;use Drupal\hello_world\HelloWorldSalutation as HelloWorldSalutationService;/** * Hello World Salutation block. * * @Block( *  id = "hello_world_salutation_block", *  admin_label = @Translation("Hello world salutation"), * ) */class HelloWorldSalutationBlock extends BlockBase implements ContainerFactoryPluginInterface {  /**   * Drupal\hello_world\HelloWorldSalutation definition.   *   * @var \Drupal\hello_world\HelloWorldSalutation   */  protected $salutation; /** ...

Get Drupal 8 Module Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.