KernelRequestListener.php in Business Rules 2.x
File
src/EventSubscriber/KernelRequestListener.php
View source
<?php
namespace Drupal\business_rules\EventSubscriber;
use Drupal\business_rules\Events\BusinessRulesEvent;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
class KernelRequestListener implements EventSubscriberInterface, ContainerAwareInterface {
use ContainerAwareTrait;
public static function getSubscribedEvents() {
return [
KernelEvents::REQUEST => [
'onKernelRequest',
1000,
],
];
}
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,
]);
$event_dispatcher = $this->container
->get('event_dispatcher');
$event_dispatcher
->dispatch($reacts_on_definition['eventName'], $new_event);
}
}