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

Commit b0c06ab

Browse files
authored
Merge pull request #91 from TavoNiievez/9.0
[9.0] Improve compatibility logic for the EventDispatcher
2 parents f5d311f + 6c240c6 commit b0c06ab

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: src/DispatcherWrapper.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Symfony\Component\EventDispatcher\Event;
66
use Symfony\Component\EventDispatcher\EventDispatcher;
7-
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
7+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;
88

99
trait DispatcherWrapper
1010
{
@@ -16,12 +16,12 @@ trait DispatcherWrapper
1616
*/
1717
protected function dispatch(EventDispatcher $dispatcher, $eventType, Event $eventObject)
1818
{
19-
//TraceableEventDispatcherInterface was introduced in symfony/event-dispatcher 2.5 and removed in 5.0
20-
if (!interface_exists(TraceableEventDispatcherInterface::class)) {
21-
//Symfony 5
19+
// The `EventDispatcherInterface` of `Symfony\Contracts` is only implemented in Symfony 4.3 or higher
20+
if ($dispatcher instanceof ContractsEventDispatcherInterface) {
21+
//Symfony 4.3 or higher
2222
$dispatcher->dispatch($eventObject, $eventType);
2323
} else {
24-
//Symfony 2,3 or 4
24+
//Symfony 4.2 or lower
2525
$dispatcher->dispatch($eventType, $eventObject);
2626
}
2727

0 commit comments

Comments
 (0)