You are here

public function ContainerAwareEventDispatcher::removeListener in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher::removeListener()
  2. 8 core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::removeListener()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php \Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher::removeListener()

Removes an event listener from the specified events.

Parameters

string $eventName The event to remove a listener from:

callable $listener The listener to remove:

Overrides EventDispatcher::removeListener

File

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

Class

ContainerAwareEventDispatcher
Lazily loads listeners and subscribers from the dependency injection container.

Namespace

Symfony\Component\EventDispatcher

Code

public function removeListener($eventName, $listener) {
  $this
    ->lazyLoad($eventName);
  if (isset($this->listenerIds[$eventName])) {
    foreach ($this->listenerIds[$eventName] as $i => $args) {
      list($serviceId, $method, $priority) = $args;
      $key = $serviceId . '.' . $method;
      if (isset($this->listeners[$eventName][$key]) && $listener === array(
        $this->listeners[$eventName][$key],
        $method,
      )) {
        unset($this->listeners[$eventName][$key]);
        if (empty($this->listeners[$eventName])) {
          unset($this->listeners[$eventName]);
        }
        unset($this->listenerIds[$eventName][$i]);
        if (empty($this->listenerIds[$eventName])) {
          unset($this->listenerIds[$eventName]);
        }
      }
    }
  }
  parent::removeListener($eventName, $listener);
}