You are here

private function TraceableEventDispatcher::postProcess in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php \Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher::postProcess()
1 call to TraceableEventDispatcher::postProcess()
TraceableEventDispatcher::dispatch in vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php
Dispatches an event to all registered listeners.

File

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

Class

TraceableEventDispatcher
Collects some data about event listeners.

Namespace

Symfony\Component\EventDispatcher\Debug

Code

private function postProcess($eventName) {
  unset($this->wrappedListeners[$eventName]);
  $skipped = false;
  foreach ($this->dispatcher
    ->getListeners($eventName) as $listener) {
    if (!$listener instanceof WrappedListener) {

      // #12845: a new listener was added during dispatch.
      continue;
    }

    // Unwrap listener
    $this->dispatcher
      ->removeListener($eventName, $listener);
    $this->dispatcher
      ->addListener($eventName, $listener
      ->getWrappedListener());
    $info = $this
      ->getListenerInfo($listener
      ->getWrappedListener(), $eventName);
    if ($listener
      ->wasCalled()) {
      if (null !== $this->logger) {
        $this->logger
          ->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty']));
      }
      if (!isset($this->called[$eventName])) {
        $this->called[$eventName] = new \SplObjectStorage();
      }
      $this->called[$eventName]
        ->attach($listener);
    }
    if (null !== $this->logger && $skipped) {
      $this->logger
        ->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName));
    }
    if ($listener
      ->stoppedPropagation()) {
      if (null !== $this->logger) {
        $this->logger
          ->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName));
      }
      $skipped = true;
    }
  }
}