You are here

hook_event_dispatcher.module in Hook Event Dispatcher 8

Same filename and directory in other branches
  1. 8.2 hook_event_dispatcher.module
  2. 3.x hook_event_dispatcher.module

Hook event dispatcher module.

File

hook_event_dispatcher.module
View source
<?php

/**
 * @file
 * Hook event dispatcher module.
 */
use Drupal\Core\Asset\AttachedAssetsInterface;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\Core\Session\AccountInterface;
use Drupal\hook_event_dispatcher\Event\Block\BlockBuildAlterEvent;
use Drupal\hook_event_dispatcher\Event\Cron\CronEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityAccessEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityBuildDefaultsAlterEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityCreateEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityDeleteEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityInsertEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityLoadEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityOperationEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityOperationAlterEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityPredeleteEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityPresaveEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityTranslationDeleteEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityTranslationInsertEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityUpdateEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityViewEvent;
use Drupal\hook_event_dispatcher\Event\Entity\EntityViewAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityExtra\EntityExtraFieldInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityExtra\EntityExtraFieldInfoEvent;
use Drupal\hook_event_dispatcher\Event\EntityField\EntityFieldAccessEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityBaseFieldInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityBaseFieldInfoEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityBundleFieldInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityTypeAlterEvent;
use Drupal\hook_event_dispatcher\Event\EntityType\EntityTypeBuildEvent;
use Drupal\hook_event_dispatcher\Event\Form\FormAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\FormBaseAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\FormIdAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\WidgetFormAlterEvent;
use Drupal\hook_event_dispatcher\Event\Form\WidgetTypeFormAlterEvent;
use Drupal\hook_event_dispatcher\Event\Language\LanguageSwitchLinksAlterEvent;
use Drupal\hook_event_dispatcher\Event\Page\PageAttachmentsEvent;
use Drupal\hook_event_dispatcher\Event\Page\PageBottomEvent;
use Drupal\hook_event_dispatcher\Event\Page\PageTopEvent;
use Drupal\hook_event_dispatcher\Event\Path\PathDeleteEvent;
use Drupal\hook_event_dispatcher\Event\Path\PathInsertEvent;
use Drupal\hook_event_dispatcher\Event\Path\PathUpdateEvent;
use Drupal\hook_event_dispatcher\Event\Theme\JsAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\LibraryInfoAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\TemplatePreprocessDefaultVariablesAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeRegistryAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeSuggestionsAlterEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemeSuggestionsAlterIdEvent;
use Drupal\hook_event_dispatcher\Event\Theme\ThemesInstalledEvent;
use Drupal\hook_event_dispatcher\Event\Token\TokensInfoEvent;
use Drupal\hook_event_dispatcher\Event\Token\TokensReplacementEvent;
use Drupal\hook_event_dispatcher\Event\Toolbar\ToolbarAlterEvent;
use Drupal\hook_event_dispatcher\Event\User\UserCancelEvent;
use Drupal\hook_event_dispatcher\Event\User\UserCancelMethodsAlterEvent;
use Drupal\hook_event_dispatcher\Event\User\UserFormatNameAlterEvent;
use Drupal\hook_event_dispatcher\Event\User\UserLoginEvent;
use Drupal\hook_event_dispatcher\Event\User\UserLogoutEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsDataAlterEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsDataEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPostBuildEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPostExecuteEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPostRenderEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPreBuildEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPreExecuteEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPreRenderEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsPreViewEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsQueryAlterEvent;
use Drupal\hook_event_dispatcher\Event\Views\ViewsQuerySubstitutionsEvent;
use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\Plugin\views\query\QueryPluginBase;
use Drupal\views\ViewExecutable;

/**
 * Implements hook_help().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_help($routeName) {
  if ($routeName === 'help.page.hook_event_dispatcher') {
    $path = \drupal_get_path('module', 'hook_event_dispatcher');
    $output = \file_get_contents($path . '/README.md');
    return '<pre>' . $output . '</pre>';
  }
  return '';
}

/**
 * Implements hook_entity_insert().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_insert(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityInsertEvent($entity));
}

/**
 * Implements hook_entity_update().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_update(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityUpdateEvent($entity));
}

/**
 * Implements hook_entity_predelete().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_predelete(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityPredeleteEvent($entity));
}

/**
 * Implements hook_entity_delete().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_delete(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityDeleteEvent($entity));
}

/**
 * Implements hook_entity_presave().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_presave(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityPresaveEvent($entity));
}

/**
 * Implements hook_entity_access().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityAccessEvent($entity, $operation, $account);
  $manager
    ->register($event);
  return $event
    ->getAccessResult();
}

/**
 * Implements hook_entity_create().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_create(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityCreateEvent($entity));
}

/**
 * Implements hook_entity_load().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_load(array $entities, $entityTypeId) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityLoadEvent($entities, $entityTypeId));
}

/**
 * Implements hook_entity_translation_insert().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_translation_insert(EntityInterface $translation) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityTranslationInsertEvent($translation));
}

/**
 * Implements hook_entity_translation_delete().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_translation_delete(EntityInterface $translation) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityTranslationDeleteEvent($translation));
}

/**
 * Implements hook_entity_view().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $viewMode) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityViewEvent($build, $entity, $display, $viewMode));
}

/**
 * Implements hook_entity_build_defaults_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_build_defaults_alter(array &$build, EntityInterface $entity, $viewMode) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityBuildDefaultsAlterEvent($build, $entity, (string) $viewMode));
}

/**
 * Implements hook_entity_view_alter().
 *
 *  * {@inheritdoc}
 */
function hook_event_dispatcher_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityViewAlterEvent($build, $entity, $display));
}

/**
 * Implements hook_entity_operation().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_operation(EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityOperationEvent($entity);
  $manager
    ->register($event);
  return $event
    ->getOperations();
}

/**
 * Implements hook_entity_operation_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_operation_alter(array &$operations, EntityInterface $entity) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new EntityOperationAlterEvent($operations, $entity));
}

/**
 * Implements hook_form_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_form_alter(&$form, FormStateInterface $formState, $formId) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new FormAlterEvent($form, $formState, $formId));
  $buildInfo = $formState
    ->getBuildInfo();
  if (!empty($buildInfo['base_form_id'])) {

    /** @var \Drupal\hook_event_dispatcher\Event\Form\FormBaseAlterEvent $event */
    $manager
      ->register(new FormBaseAlterEvent($form, $formState, $formId, $buildInfo['base_form_id']));
  }
  $manager
    ->register(new FormIdAlterEvent($form, $formState, $formId));
}

/**
 * Implements hook_field_widget_form_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_field_widget_form_alter(&$element, FormStateInterface $formState, $context) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new WidgetFormAlterEvent($element, $formState, $context));
  $manager
    ->register(new WidgetTypeFormAlterEvent($element, $formState, $context));
}

/**
 * Implements hook_preprocess().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_preprocess(&$variables, $hook) {

  /** @var \Drupal\hook_event_dispatcher\Service\PreprocessEventService $service */
  $service = \Drupal::service('preprocess_event.service');
  $service
    ->createAndDispatchKnownEvents($hook, $variables);
}

/**
 * Implements hook_template_preprocess_default_variables_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_template_preprocess_default_variables_alter(&$variables) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new TemplatePreprocessDefaultVariablesAlterEvent($variables));
}

/**
 * Implements hook_block_build_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_block_build_alter(&$build, BlockPluginInterface $block) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new BlockBuildAlterEvent($build, $block));
}

/**
 * Implements hook_tokens().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleableMetadata) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new TokensReplacementEvent($type, $tokens, $data, $options, $bubbleableMetadata);
  $manager
    ->register($event);
  return $event
    ->getReplacementValues();
}

/**
 * Implements hook_token_info().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_token_info() {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new TokensInfoEvent();
  $manager
    ->register($event);
  return [
    'types' => $event
      ->getTokenTypes(),
    'tokens' => $event
      ->getTokens(),
  ];
}

/**
 * Implements hook_path_insert().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_path_insert($path) {
  if (empty($path)) {
    return;
  }

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new PathInsertEvent($path);
  $manager
    ->register($event);
}

/**
 * Implements hook_path_update().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_path_update($path) {
  if (empty($path)) {
    return;
  }

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new PathUpdateEvent($path);
  $manager
    ->register($event);
}

/**
 * Implements hook_path_delete().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_path_delete($path) {
  if (empty($path)) {
    return;
  }

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new PathDeleteEvent($path);
  $manager
    ->register($event);
}

/**
 * Implements hook_entity_field_access().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_field_access($operation, FieldDefinitionInterface $fieldDefinition, AccountInterface $account, FieldItemListInterface $items = NULL) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityFieldAccessEvent($operation, $fieldDefinition, $account, $items);
  $manager
    ->register($event);
  return $event
    ->getAccessResult();
}

/**
 * Implements hook_entity_base_field_info().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_base_field_info(EntityTypeInterface $entityType) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityBaseFieldInfoEvent($entityType);
  $manager
    ->register($event);
  return $event
    ->getFields();
}

/**
 * Implements hook_entity_base_field_info_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_base_field_info_alter(array &$fields, EntityTypeInterface $entityType) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityBaseFieldInfoAlterEvent($fields, $entityType);
  $manager
    ->register($event);
}

/**
 * Implements hook_entity_bundle_field_info_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_bundle_field_info_alter(array &$fields, EntityTypeInterface $entityType, $bundle) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityBundleFieldInfoAlterEvent($fields, $entityType, $bundle);
  $manager
    ->register($event);
}

/**
 * Implements hook_entity_type_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_type_alter(array &$entityTypes) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityTypeAlterEvent($entityTypes);
  $manager
    ->register($event);
}

/**
 * Implements hook_entity_type_build().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_type_build(array &$entityTypes) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityTypeBuildEvent($entityTypes);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_pre_view().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_pre_view(ViewExecutable $view, $displayId, array &$args) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPreViewEvent($view, $displayId, $args);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_data().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_data() {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsDataEvent();
  $manager
    ->register($event);
  return $event
    ->getData();
}

/**
 * Implements hook_views_data_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_data_alter(array &$data) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new ViewsDataAlterEvent($data));
}

/**
 * Implements hook_views_pre_execute().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_pre_execute(ViewExecutable $view) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPreExecuteEvent($view);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_post_execute().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_post_execute(ViewExecutable $view) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPostExecuteEvent($view);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_pre_build().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_pre_build(ViewExecutable $view) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPreBuildEvent($view);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_post_build().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_post_build(ViewExecutable $view) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPostBuildEvent($view);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_pre_render().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_pre_render(ViewExecutable $view) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPreRenderEvent($view);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_post_render().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsPostRenderEvent($view, $output, $cache);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_query_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsQueryAlterEvent($view, $query);
  $manager
    ->register($event);
}

/**
 * Implements hook_views_query_substitutions().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_views_query_substitutions(ViewExecutable $view) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ViewsQuerySubstitutionsEvent($view);
  $manager
    ->register($event);
  return $event
    ->getSubstitutions();
}

/**
 * Implements hook_entity_extra_field_info().
 */
function hook_event_dispatcher_entity_extra_field_info() {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityExtraFieldInfoEvent();
  $manager
    ->register($event);
  return $event
    ->getFieldInfo();
}

/**
 * Implements hook_entity_extra_field_info_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_entity_extra_field_info_alter(array &$info) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new EntityExtraFieldInfoAlterEvent($info);
  $manager
    ->register($event);
}

/**
 * Implements hook_theme_suggestions_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new ThemeSuggestionsAlterEvent($suggestions, $variables, $hook));
  $manager
    ->register(new ThemeSuggestionsAlterIdEvent($suggestions, $variables, $hook));
}

/**
 * Implements hook_themes_installed().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_themes_installed(array $themeList) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new ThemesInstalledEvent($themeList));
}

/**
 * Implements hook_theme().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_theme(array $existing) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ThemeEvent($existing);
  $manager
    ->register($event);
  return $event
    ->getNewThemes();
}

/**
 * Implements hook_theme_registry_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_theme_registry_alter(array &$themeRegistry) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $manager
    ->register(new ThemeRegistryAlterEvent($themeRegistry));
}

/**
 * Implements hook_user_cancel().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_user_cancel(array $edit, AccountInterface $account, $method) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new UserCancelEvent($edit, $account, $method);
  $manager
    ->register($event);
}

/**
 * Implements hook_user_cancel_methods_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_user_cancel_methods_alter(array &$methods) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new UserCancelMethodsAlterEvent($methods);
  $manager
    ->register($event);
}

/**
 * Implements hook_user_login().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_user_login(AccountInterface $account) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new UserLoginEvent($account);
  $manager
    ->register($event);
}

/**
 * Implements hook_user_logout().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_user_logout(AccountInterface $account) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new UserLogoutEvent($account);
  $manager
    ->register($event);
}

/**
 * Implements hook_user_format_name_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_user_format_name_alter(&$name, AccountInterface $account) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new UserFormatNameAlterEvent($name, $account);
  $manager
    ->register($event);
}

/**
 * Implements hook_toolbar_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_toolbar_alter(array &$items) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new ToolbarAlterEvent($items);
  $manager
    ->register($event);
}

/**
 * Implements hook_js_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_js_alter(array &$javascript, AttachedAssetsInterface $assets) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new JsAlterEvent($javascript, $assets);
  $manager
    ->register($event);
}

/**
 * Implements hook_library_info_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_library_info_alter(array &$libraries, $extension) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new LibraryInfoAlterEvent($libraries, $extension);
  $manager
    ->register($event);
}

/**
 * Implements hook_page_top().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_page_top(array &$pageTop) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new PageTopEvent($pageTop);
  $manager
    ->register($event);
}

/**
 * Implements hook_page_bottom().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_page_bottom(array &$pageBottom) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new PageBottomEvent($pageBottom);
  $manager
    ->register($event);
}

/**
 * Implements hook_page_attachments().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_page_attachments(array &$attachments) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new PageAttachmentsEvent($attachments);
  $manager
    ->register($event);
}

/**
 * Implements hook_cron().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_cron() {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new CronEvent();
  $manager
    ->register($event);
}

/**
 * Implements hook_language_switch_links_alter().
 *
 * {@inheritdoc}
 */
function hook_event_dispatcher_language_switch_links_alter(array &$links, $type, $path) {

  /** @var \Drupal\hook_event_dispatcher\Manager\HookEventDispatcherManagerInterface $manager */
  $manager = \Drupal::service('hook_event_dispatcher.manager');
  $event = new LanguageSwitchLinksAlterEvent($links, $type, $path);
  $manager
    ->register($event);
}

Functions

Namesort descending Description
hook_event_dispatcher_block_build_alter Implements hook_block_build_alter().
hook_event_dispatcher_cron Implements hook_cron().
hook_event_dispatcher_entity_access Implements hook_entity_access().
hook_event_dispatcher_entity_base_field_info Implements hook_entity_base_field_info().
hook_event_dispatcher_entity_base_field_info_alter Implements hook_entity_base_field_info_alter().
hook_event_dispatcher_entity_build_defaults_alter Implements hook_entity_build_defaults_alter().
hook_event_dispatcher_entity_bundle_field_info_alter Implements hook_entity_bundle_field_info_alter().
hook_event_dispatcher_entity_create Implements hook_entity_create().
hook_event_dispatcher_entity_delete Implements hook_entity_delete().
hook_event_dispatcher_entity_extra_field_info Implements hook_entity_extra_field_info().
hook_event_dispatcher_entity_extra_field_info_alter Implements hook_entity_extra_field_info_alter().
hook_event_dispatcher_entity_field_access Implements hook_entity_field_access().
hook_event_dispatcher_entity_insert Implements hook_entity_insert().
hook_event_dispatcher_entity_load Implements hook_entity_load().
hook_event_dispatcher_entity_operation Implements hook_entity_operation().
hook_event_dispatcher_entity_operation_alter Implements hook_entity_operation_alter().
hook_event_dispatcher_entity_predelete Implements hook_entity_predelete().
hook_event_dispatcher_entity_presave Implements hook_entity_presave().
hook_event_dispatcher_entity_translation_delete Implements hook_entity_translation_delete().
hook_event_dispatcher_entity_translation_insert Implements hook_entity_translation_insert().
hook_event_dispatcher_entity_type_alter Implements hook_entity_type_alter().
hook_event_dispatcher_entity_type_build Implements hook_entity_type_build().
hook_event_dispatcher_entity_update Implements hook_entity_update().
hook_event_dispatcher_entity_view Implements hook_entity_view().
hook_event_dispatcher_entity_view_alter Implements hook_entity_view_alter().
hook_event_dispatcher_field_widget_form_alter Implements hook_field_widget_form_alter().
hook_event_dispatcher_form_alter Implements hook_form_alter().
hook_event_dispatcher_help Implements hook_help().
hook_event_dispatcher_js_alter Implements hook_js_alter().
hook_event_dispatcher_language_switch_links_alter Implements hook_language_switch_links_alter().
hook_event_dispatcher_library_info_alter Implements hook_library_info_alter().
hook_event_dispatcher_page_attachments Implements hook_page_attachments().
hook_event_dispatcher_page_bottom Implements hook_page_bottom().
hook_event_dispatcher_page_top Implements hook_page_top().
hook_event_dispatcher_path_delete Implements hook_path_delete().
hook_event_dispatcher_path_insert Implements hook_path_insert().
hook_event_dispatcher_path_update Implements hook_path_update().
hook_event_dispatcher_preprocess Implements hook_preprocess().
hook_event_dispatcher_template_preprocess_default_variables_alter Implements hook_template_preprocess_default_variables_alter().
hook_event_dispatcher_theme Implements hook_theme().
hook_event_dispatcher_themes_installed Implements hook_themes_installed().
hook_event_dispatcher_theme_registry_alter Implements hook_theme_registry_alter().
hook_event_dispatcher_theme_suggestions_alter Implements hook_theme_suggestions_alter().
hook_event_dispatcher_tokens Implements hook_tokens().
hook_event_dispatcher_token_info Implements hook_token_info().
hook_event_dispatcher_toolbar_alter Implements hook_toolbar_alter().
hook_event_dispatcher_user_cancel Implements hook_user_cancel().
hook_event_dispatcher_user_cancel_methods_alter Implements hook_user_cancel_methods_alter().
hook_event_dispatcher_user_format_name_alter Implements hook_user_format_name_alter().
hook_event_dispatcher_user_login Implements hook_user_login().
hook_event_dispatcher_user_logout Implements hook_user_logout().
hook_event_dispatcher_views_data Implements hook_views_data().
hook_event_dispatcher_views_data_alter Implements hook_views_data_alter().
hook_event_dispatcher_views_post_build Implements hook_views_post_build().
hook_event_dispatcher_views_post_execute Implements hook_views_post_execute().
hook_event_dispatcher_views_post_render Implements hook_views_post_render().
hook_event_dispatcher_views_pre_build Implements hook_views_pre_build().
hook_event_dispatcher_views_pre_execute Implements hook_views_pre_execute().
hook_event_dispatcher_views_pre_render Implements hook_views_pre_render().
hook_event_dispatcher_views_pre_view Implements hook_views_pre_view().
hook_event_dispatcher_views_query_alter Implements hook_views_query_alter().
hook_event_dispatcher_views_query_substitutions Implements hook_views_query_substitutions().