8.5.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)
8.0.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)
8.1.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)
8.2.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)
8.3.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)
8.4.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)
8.6.x EventDispatcher.php EventDispatcher::removeListener($eventName, $listener)

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 EventDispatcherInterface::removeListener

2 calls to EventDispatcher::removeListener()
ContainerAwareEventDispatcher::removeListener in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Removes an event listener from the specified events.
EventDispatcher::removeSubscriber in vendor/symfony/event-dispatcher/EventDispatcher.php
Removes an event subscriber.
1 method overrides EventDispatcher::removeListener()
ContainerAwareEventDispatcher::removeListener in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Removes an event listener from the specified events.

File

vendor/symfony/event-dispatcher/EventDispatcher.php, line 121

Class

EventDispatcher
The EventDispatcherInterface is the central point of Symfony's event listener system.

Namespace

Symfony\Component\EventDispatcher

Code

public function removeListener($eventName, $listener) {
  if (!isset($this->listeners[$eventName])) {
    return;
  }
  foreach ($this->listeners[$eventName] as $priority => $listeners) {
    if (false !== ($key = array_search($listener, $listeners, true))) {
      unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]);
    }
  }
}