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

[7.1] Improve compatibility logic for the EventDispatcher #93

Merged
merged 1 commit into from
Dec 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/DispatcherWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface as ContractsEventDispatcherInterface;

trait DispatcherWrapper
{
Expand All @@ -16,12 +16,12 @@ trait DispatcherWrapper
*/
protected function dispatch(EventDispatcher $dispatcher, $eventType, Event $eventObject)
{
//TraceableEventDispatcherInterface was introduced in symfony/event-dispatcher 2.5 and removed in 5.0
if (!interface_exists(TraceableEventDispatcherInterface::class)) {
//Symfony 5
// The `EventDispatcherInterface` of `Symfony\Contracts` is only implemented in Symfony 4.3 or higher
if ($dispatcher instanceof ContractsEventDispatcherInterface) {
//Symfony 4.3 or higher
$dispatcher->dispatch($eventObject, $eventType);
} else {
//Symfony 2,3 or 4
//Symfony 4.2 or lower
$dispatcher->dispatch($eventType, $eventObject);
}

Expand Down