You are here

protected function ContainerAwareEventDispatcher::lazyLoad in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php \Symfony\Component\EventDispatcher\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.

2 calls to ContainerAwareEventDispatcher::lazyLoad()
ContainerAwareEventDispatcher::getListeners in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Gets the listeners of a specific event or all listeners sorted by descending priority.
ContainerAwareEventDispatcher::removeListener in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Removes an event listener from the specified events.

File

vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php, line 168

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;
    }
  }
}