Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit fc5b730

Browse files
committed
Improved detection of event-dispatcher version
Previous detector used class from symfony/event-dispatcher-contracts so it wasn't precise enough. TraceableEventDispatcherInterface was a part of event-dispatcher, so it is more accurate
1 parent 208db4d commit fc5b730

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: src/DispatcherWrapper.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Symfony\Component\EventDispatcher\Event;
66
use Symfony\Component\EventDispatcher\EventDispatcher;
7+
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
78

89
trait DispatcherWrapper
910
{
@@ -15,7 +16,8 @@ trait DispatcherWrapper
1516
*/
1617
protected function dispatch(EventDispatcher $dispatcher, $eventType, Event $eventObject)
1718
{
18-
if (class_exists('Symfony\Contracts\EventDispatcher\Event')) {
19+
//TraceableEventDispatcherInterface was introduced in symfony/event-dispatcher 2.5 and removed in 5.0
20+
if (!interface_exists(TraceableEventDispatcherInterface::class)) {
1921
//Symfony 5
2022
$dispatcher->dispatch($eventObject, $eventType);
2123
} else {

0 commit comments

Comments
 (0)