drupal_hook_events.info.yml name: 'Drupal hook events' description: 'Events Subscriber instead of hooks' type: module core: 8.x dependencies: - 'drupal:hook_event_dispatcher' drupal_hook_events.services.yml services: preprocess.hook_entity_view: class: 'Drupal\drupal_hook_events\EventSubscriber\EntityViewSubScriber' tags: - { name: 'event_subscriber' } drupal_hook_events/src/EventSubscriber/EntityViewSubScriber.php <?php namespace Drupal\drupal_hook_events\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Drupal\hook_event_dispatcher\HookEventDispatcherInterface; /** * Class EntityViewModeAlterEventSubScriber. */ class EntityViewSubScriber implements EventSubscriberInterface { /** * {@inheritdoc} */ public static function getSubscribedEvents() { return [ HookEventDispatcherInterface::ENTITY_VIEW ...