public function PreprocessEventService::createAndDispatchKnownEvents in Hook Event Dispatcher 8.2
Same name and namespace in other branches
- 3.x modules/preprocess_event_dispatcher/src/Service/PreprocessEventService.php \Drupal\preprocess_event_dispatcher\Service\PreprocessEventService::createAndDispatchKnownEvents()
Create and dispatch the event.
Parameters
string $hook: The hook name.
array $variables: Variables.
Overrides PreprocessEventServiceInterface::createAndDispatchKnownEvents
File
- modules/
preprocess_event_dispatcher/ src/ Service/ PreprocessEventService.php, line 43
Class
- PreprocessEventService
- Class PreprocessEventService.
Namespace
Drupal\preprocess_event_dispatcher\ServiceCode
public function createAndDispatchKnownEvents(string $hook, array &$variables) : void {
$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);
}
}