collect called listeners information only once
This commit is contained in:
parent
bde8204da3
commit
284262a219
@ -224,22 +224,22 @@ class TraceableEventDispatcher implements TraceableEventDispatcherInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null;
|
$hash = 1 <= \func_num_args() && null !== ($request = \func_get_arg(0)) ? spl_object_hash($request) : null;
|
||||||
$notCalled = [];
|
$calledListeners = [];
|
||||||
foreach ($allListeners as $eventName => $listeners) {
|
|
||||||
foreach ($listeners as $listener) {
|
|
||||||
$called = false;
|
|
||||||
if (null !== $this->callStack) {
|
if (null !== $this->callStack) {
|
||||||
foreach ($this->callStack as $calledListener) {
|
foreach ($this->callStack as $calledListener) {
|
||||||
list(, $requestHash) = $this->callStack->getInfo();
|
list(, $requestHash) = $this->callStack->getInfo();
|
||||||
if ((null === $hash || $hash === $requestHash) && $calledListener->getWrappedListener() === $listener) {
|
|
||||||
$called = true;
|
|
||||||
|
|
||||||
break;
|
if (null === $hash || $hash === $requestHash) {
|
||||||
|
$calledListeners[] = $calledListener->getWrappedListener();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$called) {
|
$notCalled = [];
|
||||||
|
foreach ($allListeners as $eventName => $listeners) {
|
||||||
|
foreach ($listeners as $listener) {
|
||||||
|
if (!\in_array($listener, $calledListeners, true)) {
|
||||||
if (!$listener instanceof WrappedListener) {
|
if (!$listener instanceof WrappedListener) {
|
||||||
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
|
$listener = new WrappedListener($listener, null, $this->stopwatch, $this);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user