You are here

public function KernelRequestListener::onKernelRequest in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/KernelRequestListener.php \Drupal\business_rules\EventSubscriber\KernelRequestListener::onKernelRequest()

Create a new event for BusinessRules plugin KernelRequest.

Parameters

\Symfony\Component\EventDispatcher\Event $event: The event.

File

src/EventSubscriber/KernelRequestListener.php, line 37

Class

KernelRequestListener
Class KernelRequestListener.

Namespace

Drupal\business_rules\EventSubscriber

Code

public function onKernelRequest(Event $event) {
  $reacts_on_definition = $this->container
    ->get('plugin.manager.business_rules.reacts_on')
    ->getDefinition('kernel_request');
  $new_event = new BusinessRulesEvent(NULL, [
    'entity_type_id' => NULL,
    'bundle' => NULL,
    'entity' => NULL,
    'entity_unchanged' => NULL,
    'reacts_on' => $reacts_on_definition,
  ]);

  /** @var \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher */
  $event_dispatcher = $this->container
    ->get('event_dispatcher');
  $event_dispatcher
    ->dispatch($reacts_on_definition['eventName'], $new_event);
}