You are here

public function EventDispatcher::dispatch in Zircon Profile 8

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

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;
}