You are here

toolbar_event_dispatcher.module in Hook Event Dispatcher 3.x

Same filename and directory in other branches
  1. 8.2 modules/toolbar_event_dispatcher/toolbar_event_dispatcher.module

Toolbar event dispatcher submodule.

File

modules/toolbar_event_dispatcher/toolbar_event_dispatcher.module
View source
<?php

/**
 * @file
 * Toolbar event dispatcher submodule.
 */
use Drupal\toolbar_event_dispatcher\Event\Toolbar\ToolbarAlterEvent;
use Drupal\toolbar_event_dispatcher\Event\Toolbar\ToolbarEvent;

/**
 * Implements hook_toolbar_alter().
 *
 * {@inheritdoc}
 */
function toolbar_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_toolbar().
 *
 * {@inheritdoc}
 */
function toolbar_event_dispatcher_toolbar() {

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