protected function ContainerAwareEventDispatcher::lazyLoad

Lazily loads listeners for this event from the dependency injection container.

Parameters

string $eventName The name of the event to dispatch. The name of: the event is the name of the method that is invoked on listeners.

4 calls to ContainerAwareEventDispatcher::lazyLoad()
ContainerAwareEventDispatcher::dispatch in drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
Lazily loads listeners for this event from the dependency injection container.
ContainerAwareEventDispatcher::getListeners in drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
ContainerAwareEventDispatcher::removeListener in drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
Removes an event listener from the specified events.
ContainerAwareTraceableEventDispatcher::lazyLoad in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php
Lazily loads listeners for this event from the dependency injection container.
1 method overrides ContainerAwareEventDispatcher::lazyLoad()
ContainerAwareTraceableEventDispatcher::lazyLoad in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/ContainerAwareTraceableEventDispatcher.php
Lazily loads listeners for this event from the dependency injection container.

File

drupal/core/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php, line 181

Class

ContainerAwareEventDispatcher
Lazily loads listeners and subscribers from the dependency injection container

Namespace

Symfony\Component\EventDispatcher

Code

protected function lazyLoad($eventName) {
  if (isset($this->listenerIds[$eventName])) {
    foreach ($this->listenerIds[$eventName] as $args) {
      list($serviceId, $method, $priority) = $args;
      $listener = $this->container
        ->get($serviceId);
      $key = $serviceId . '.' . $method;
      if (!isset($this->listeners[$eventName][$key])) {
        $this
          ->addListener($eventName, array(
          $listener,
          $method,
        ), $priority);
      }
      elseif ($listener !== $this->listeners[$eventName][$key]) {
        parent::removeListener($eventName, array(
          $this->listeners[$eventName][$key],
          $method,
        ));
        $this
          ->addListener($eventName, array(
          $listener,
          $method,
        ), $priority);
      }
      $this->listeners[$eventName][$key] = $listener;
    }
  }
}