[EventDispatcher] Fix BC layer

This commit is contained in:
Robin Chalas 2019-03-31 13:27:47 +02:00
parent cbbfe84154
commit caa0aded89

View File

@ -230,7 +230,20 @@ class EventDispatcher implements EventDispatcherInterface
*/
protected function callListeners(iterable $listeners, string $eventName, $event)
{
$this->doDispatch($listeners, $eventName, $event);
if ($event instanceof Event) {
$this->doDispatch($listeners, $eventName, $event);
return;
}
$stoppable = $event instanceof ContractsEvent || $event instanceof StoppableEventInterface;
foreach ($listeners as $listener) {
if ($stoppable && $event->isPropagationStopped()) {
break;
}
$listener($event, $eventName, $this);
}
}
/**
@ -238,10 +251,8 @@ class EventDispatcher implements EventDispatcherInterface
*/
protected function doDispatch($listeners, $eventName, Event $event)
{
$stoppable = $event instanceof Event || $event instanceof ContractsEvent || $event instanceof StoppableEventInterface;
foreach ($listeners as $listener) {
if ($stoppable && $event->isPropagationStopped()) {
if ($event->isPropagationStopped()) {
break;
}
$listener($event, $eventName, $this);