You are here

public function PreprocessEventService::createAndDispatchKnownEvents in Hook Event Dispatcher 8

Create and dispatch the event.

Parameters

string $hook: The hook name.

array $variables: Variables.

File

src/Service/PreprocessEventService.php, line 48

Class

PreprocessEventService
Class PreprocessEventService.

Namespace

Drupal\hook_event_dispatcher\Service

Code

public function createAndDispatchKnownEvents($hook, array &$variables) {
  $factory = $this->mapper
    ->getFactory($hook);
  if ($factory === NULL) {
    return;
  }
  $event = $factory
    ->createEvent($variables);
  $this->dispatcher
    ->dispatch($event::name(), $event);
  if ($event instanceof PreprocessEntityEventInterface) {
    $this
      ->dispatchEntitySpecificEvents($event);
  }
}