You are here

class KernelRequestListener in Business Rules 8

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

Class KernelRequestListener.

Provides the subscribed event for the plugin BusinessRulesReactsOn\KernelRequest.

@package Drupal\business_rules\EventSubscriber

Hierarchy

  • class \Drupal\business_rules\EventSubscriber\KernelRequestListener implements \Symfony\Component\EventDispatcher\EventSubscriberInterface, \Symfony\Component\DependencyInjection\ContainerAwareInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait

Expanded class hierarchy of KernelRequestListener

1 string reference to 'KernelRequestListener'
business_rules.services.yml in ./business_rules.services.yml
business_rules.services.yml
1 service uses KernelRequestListener
business_rules.kernel_request in ./business_rules.services.yml
Drupal\business_rules\EventSubscriber\KernelRequestListener

File

src/EventSubscriber/KernelRequestListener.php, line 20

Namespace

Drupal\business_rules\EventSubscriber
View source
class KernelRequestListener implements EventSubscriberInterface, ContainerAwareInterface {
  use ContainerAwareTrait;

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    return [
      KernelEvents::REQUEST => [
        'onKernelRequest',
        1000,
      ],
    ];
  }

  /**
   * Create a new event for BusinessRules plugin KernelRequest.
   *
   * @param \Symfony\Component\EventDispatcher\Event $event
   *   The event.
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
KernelRequestListener::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
KernelRequestListener::onKernelRequest public function Create a new event for BusinessRules plugin KernelRequest.