8.5.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)
8.0.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)
8.1.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)
8.2.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)
8.3.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)
8.4.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)
8.6.x EventDispatcher.php EventDispatcher::getListeners($eventName = null)

Gets the listeners of a specific event or all listeners sorted by descending priority.

Parameters

string $eventName The name of the event:

Return value

array The event listeners for the specified event, or all event listeners by event name

Overrides EventDispatcherInterface::getListeners

2 calls to EventDispatcher::getListeners()
ContainerAwareEventDispatcher::getListeners in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Gets the listeners of a specific event or all listeners sorted by descending priority.
EventDispatcher::hasListeners in vendor/symfony/event-dispatcher/EventDispatcher.php
Checks whether an event has any registered listeners.
1 method overrides EventDispatcher::getListeners()
ContainerAwareEventDispatcher::getListeners in vendor/symfony/event-dispatcher/ContainerAwareEventDispatcher.php
Gets the listeners of a specific event or all listeners sorted by descending priority.

File

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

Class

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

Namespace

Symfony\Component\EventDispatcher

Code

public function getListeners($eventName = null) {
  if (null !== $eventName) {
    if (!isset($this->listeners[$eventName])) {
      return array();
    }
    if (!isset($this->sorted[$eventName])) {
      $this
        ->sortListeners($eventName);
    }
    return $this->sorted[$eventName];
  }
  foreach ($this->listeners as $eventName => $eventListeners) {
    if (!isset($this->sorted[$eventName])) {
      $this
        ->sortListeners($eventName);
    }
  }
  return array_filter($this->sorted);
}