Skip to content

Commit

Permalink
Improved detection of event-dispatcher version
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Naktibalda committed Dec 21, 2019
1 parent ee0c1fa commit 2bba858
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/DispatcherWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;

trait DispatcherWrapper
{
Expand All @@ -15,7 +16,8 @@ trait DispatcherWrapper
*/
protected function dispatch(EventDispatcher $dispatcher, $eventType, Event $eventObject)
{
if (class_exists('Symfony\Contracts\EventDispatcher\Event')) {
//TraceableEventDispatcherInterface was introduced in symfony/event-dispatcher 2.5 and removed in 5.0
if (!interface_exists(TraceableEventDispatcherInterface::class)) {
//Symfony 5
$dispatcher->dispatch($eventObject, $eventType);
} else {
Expand Down

0 comments on commit 2bba858

Please sign in to comment.