8.5.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)
8.0.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)
8.1.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)
8.2.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)
8.3.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)
8.4.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)
8.6.x EventDispatcher.php EventDispatcher::dispatch($eventName, Event $event = null)

Dispatches an event to all registered listeners.

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

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

Class

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

Namespace

Symfony\Component\EventDispatcher

Code

public function dispatch($eventName, Event $event = null) {
  if (null === $event) {
    $event = new Event();
  }
  $event
    ->setDispatcher($this);
  $event
    ->setName($eventName);
  if ($listeners = $this
    ->getListeners($eventName)) {
    $this
      ->doDispatch($listeners, $eventName, $event);
  }
  return $event;
}