public function TraceableEventDispatcher::dispatch

Dispatches an event to all registered listeners.

@api

Parameters

string $eventName The name of the event to dispatch. The name of: the event is the name of the method that is invoked on listeners.

Event $event The event to pass to the event handlers/listeners.: If not supplied, an empty Event instance is created.

Return value

Event

Overrides EventDispatcherInterface::dispatch

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/Debug/TraceableEventDispatcher.php, line 121

Class

TraceableEventDispatcher
Collects some data about event listeners.

Namespace

Symfony\Component\HttpKernel\Debug

Code

public function dispatch($eventName, Event $event = null) {
  if (null === $event) {
    $event = new Event();
  }
  $this->id = spl_object_hash($event);
  $this
    ->preDispatch($eventName, $event);
  $e = $this->stopwatch
    ->start($eventName, 'section');
  $this->firstCalledEvent[$eventName] = $this->stopwatch
    ->start($eventName . '.loading', 'event_listener_loading');
  if (!$this->dispatcher
    ->hasListeners($eventName)) {
    $this->firstCalledEvent[$eventName]
      ->stop();
  }
  $this->dispatcher
    ->dispatch($eventName, $event);

  // reset the id as another event might have been dispatched during the dispatching of this event
  $this->id = spl_object_hash($event);
  unset($this->firstCalledEvent[$eventName]);
  $e
    ->stop();
  $this
    ->postDispatch($eventName, $event);
  return $event;
}