[EventDispatcher] Fix unknown priority

This commit is contained in:
Roland Franssen 2019-01-08 19:04:22 +01:00
parent 47d26f6f70
commit 9fb619ac62

View File

@ -29,6 +29,7 @@ class WrappedListener
private $dispatcher;
private $pretty;
private $stub;
private $priority;
private static $hasClassStub;
public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null)
@ -96,7 +97,7 @@ class WrappedListener
return [
'event' => $eventName,
'priority' => null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null,
'priority' => null !== $this->priority ? $this->priority : (null !== $this->dispatcher ? $this->dispatcher->getListenerPriority($eventName, $this->listener) : null),
'pretty' => $this->pretty,
'stub' => $this->stub,
];
@ -104,11 +105,14 @@ class WrappedListener
public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher)
{
$dispatcher = $this->dispatcher ?: $dispatcher;
$this->called = true;
$this->priority = $dispatcher->getListenerPriority($eventName, $this->listener);
$e = $this->stopwatch->start($this->name, 'event_listener');
\call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher);
\call_user_func($this->listener, $event, $eventName, $dispatcher);
if ($e->isStarted()) {
$e->stop();