You are here

public function TraceableEventDispatcher::getNotCalledListeners in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php \Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher::getNotCalledListeners()

Gets the not called listeners.

Return value

array An array of not called listeners

Overrides TraceableEventDispatcherInterface::getNotCalledListeners

File

vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php, line 155

Class

TraceableEventDispatcher
Collects some data about event listeners.

Namespace

Symfony\Component\EventDispatcher\Debug

Code

public function getNotCalledListeners() {
  try {
    $allListeners = $this
      ->getListeners();
  } catch (\Exception $e) {
    if (null !== $this->logger) {
      $this->logger
        ->info('An exception was thrown while getting the uncalled listeners.', array(
        'exception' => $e,
      ));
    }

    // unable to retrieve the uncalled listeners
    return array();
  }
  $notCalled = array();
  foreach ($allListeners as $eventName => $listeners) {
    foreach ($listeners as $listener) {
      $called = false;
      if (isset($this->called[$eventName])) {
        foreach ($this->called[$eventName] as $l) {
          if ($l
            ->getWrappedListener() === $listener) {
            $called = true;
            break;
          }
        }
      }
      if (!$called) {
        $info = $this
          ->getListenerInfo($listener, $eventName);
        $notCalled[$eventName . '.' . $info['pretty']] = $info;
      }
    }
  }
  return $notCalled;
}