Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. TraceableEventDispatcher.php

function 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 262

Class

TraceableEventDispatcher
Collects some data about event listeners.

Namespace

Symfony\Component\EventDispatcher\Debug

Code

private function postProcess(string $eventName) : void {
    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
        $priority = $this->getListenerPriority($eventName, $listener);
        $this->dispatcher
            ->removeListener($eventName, $listener);
        $this->dispatcher
            ->addListener($eventName, $listener->getWrappedListener(), $priority);
        if (null !== $this->logger) {
            $context = [
                'event' => $eventName,
                'listener' => $listener->getPretty(),
            ];
        }
        if ($listener->wasCalled()) {
            $this->logger?->debug('Notified event "{event}" to listener "{listener}".', $context);
        }
        else {
            $this->callStack
                ->detach($listener);
        }
        if (null !== $this->logger && $skipped) {
            $this->logger
                ->debug('Listener "{listener}" was not called for event "{event}".', $context);
        }
        if ($listener->stoppedPropagation()) {
            $this->logger?->debug('Listener "{listener}" stopped propagation of the event "{event}".', $context);
            $skipped = true;
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal