collect called listeners information only once

This commit is contained in:
Christian Flothmann 2019-06-25 09:45:31 +02:00
parent 57d73fcac3
commit 2ad32df6e0

View File

@ -191,21 +191,18 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
return []; return [];
} }
$calledListeners = [];
if (null !== $this->callStack) {
foreach ($this->callStack as $calledListener) {
$calledListeners[] = $calledListener->getWrappedListener();
}
}
$notCalled = []; $notCalled = [];
foreach ($allListeners as $eventName => $listeners) { foreach ($allListeners as $eventName => $listeners) {
foreach ($listeners as $listener) { foreach ($listeners as $listener) {
$called = false; if (!\in_array($listener, $calledListeners, true)) {
if (null !== $this->callStack) {
foreach ($this->callStack as $calledListener) {
if ($calledListener->getWrappedListener() === $listener) {
$called = true;
break;
}
}
}
if (!$called) {
if (!$listener instanceof WrappedListener) { if (!$listener instanceof WrappedListener) {
$listener = new WrappedListener($listener, null, $this->stopwatch, $this); $listener = new WrappedListener($listener, null, $this->stopwatch, $this);
} }