You are here

public function EventDispatcher::removeListener in Zircon Profile 8

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

3 calls to EventDispatcher::removeListener()
ContainerAwareEventDispatcher::lazyLoad in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Lazily loads listeners for this event from the dependency injection container.
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 98

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