Skip to content

Commit

Permalink
Merge pull request #91 from TavoNiievez/9.0
Browse files Browse the repository at this point in the history
[9.0] Improve compatibility logic for the EventDispatcher
  • Loading branch information
Naktibalda authored Dec 28, 2020
2 parents f5d311f + 6c240c6 commit b0c06ab
Showing 1 changed file with 5 additions and 5 deletions.
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

0 comments on commit b0c06ab

Please sign in to comment.