Loading core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php +4 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\Component\EventDispatcher; use Psr\EventDispatcher\StoppableEventInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; Loading Loading @@ -95,6 +96,8 @@ public function dispatch(object $event, ?string $eventName = NULL): object { unset($this->unsorted[$event_name]); } $stoppable = $event instanceof StoppableEventInterface; // Invoke listeners and resolve callables if necessary. foreach ($this->listeners[$event_name] as &$definitions) { foreach ($definitions as &$definition) { Loading @@ -106,7 +109,7 @@ public function dispatch(object $event, ?string $eventName = NULL): object { } call_user_func($definition['callable'], $event, $event_name, $this); if ($event->isPropagationStopped()) { if ($stoppable && $event->isPropagationStopped()) { return $event; } } Loading core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php +3 −1 Original line number Diff line number Diff line Loading @@ -312,6 +312,8 @@ public function testDispatch() { $this->assertFalse($this->listener->postFooInvoked); $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent')); $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::PREFOO)); // Any kind of object can be dispatched, not only instances of Event. $this->assertInstanceOf(\stdClass::class, $this->dispatcher->dispatch(new \stdClass(), self::PREFOO)); $event = new Event(); $return = $this->dispatcher->dispatch($event, self::PREFOO); $this->assertSame($event, $return); Loading Loading @@ -566,7 +568,7 @@ class TestEventListener { /** * Listener methods. */ public function preFoo(Event $e) { public function preFoo(object $e) { $this->preFooInvoked = TRUE; } Loading Loading
core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php +4 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ namespace Drupal\Component\EventDispatcher; use Psr\EventDispatcher\StoppableEventInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; Loading Loading @@ -95,6 +96,8 @@ public function dispatch(object $event, ?string $eventName = NULL): object { unset($this->unsorted[$event_name]); } $stoppable = $event instanceof StoppableEventInterface; // Invoke listeners and resolve callables if necessary. foreach ($this->listeners[$event_name] as &$definitions) { foreach ($definitions as &$definition) { Loading @@ -106,7 +109,7 @@ public function dispatch(object $event, ?string $eventName = NULL): object { } call_user_func($definition['callable'], $event, $event_name, $this); if ($event->isPropagationStopped()) { if ($stoppable && $event->isPropagationStopped()) { return $event; } } Loading
core/tests/Drupal/Tests/Component/EventDispatcher/ContainerAwareEventDispatcherTest.php +3 −1 Original line number Diff line number Diff line Loading @@ -312,6 +312,8 @@ public function testDispatch() { $this->assertFalse($this->listener->postFooInvoked); $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), 'noevent')); $this->assertInstanceOf(Event::class, $this->dispatcher->dispatch(new Event(), self::PREFOO)); // Any kind of object can be dispatched, not only instances of Event. $this->assertInstanceOf(\stdClass::class, $this->dispatcher->dispatch(new \stdClass(), self::PREFOO)); $event = new Event(); $return = $this->dispatcher->dispatch($event, self::PREFOO); $this->assertSame($event, $return); Loading Loading @@ -566,7 +568,7 @@ class TestEventListener { /** * Listener methods. */ public function preFoo(Event $e) { public function preFoo(object $e) { $this->preFooInvoked = TRUE; } Loading