Triggers the listeners of an event.
This method can be overridden to add functionality that is executed for each listener.
array[callback] $listeners The event listeners.:
string $eventName The name of the event to dispatch.:
Event $event The event object to pass to the event handlers/listeners.:
Overrides EventDispatcher::doDispatch
protected function doDispatch($listeners, $eventName, Event $event) {
foreach ($listeners as $listener) {
$info = $this
->getListenerInfo($listener, $eventName);
if (null !== $this->logger) {
$this->logger
->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty']));
}
$this->called[$eventName . '.' . $info['pretty']] = $info;
$e2 = $this->stopwatch
->start(isset($info['class']) ? substr($info['class'], strrpos($info['class'], '\\') + 1) : $info['type'], 'event_listener');
call_user_func($listener, $event);
$e2
->stop();
if ($event
->isPropagationStopped()) {
if (null !== $this->logger) {
$this->logger
->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName));
$skippedListeners = $this
->getListeners($eventName);
$skipped = false;
foreach ($skippedListeners as $skippedListener) {
if ($skipped) {
$info = $this
->getListenerInfo($skippedListener, $eventName);
$this->logger
->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName));
}
if ($skippedListener === $listener) {
$skipped = true;
}
}
}
break;
}
}
}