modify plugin name
This commit is contained in:
+5
-3
@@ -36,17 +36,19 @@ class EventDispatch extends Component implements EventDispatcherInterface
|
||||
*/
|
||||
public function dispatch(object $event): object
|
||||
{
|
||||
/** @var \SplPriorityQueue $lists */
|
||||
$lists = $this->eventProvider->getListenersForEvent($event);
|
||||
foreach ($lists as $listener) {
|
||||
/** @var Struct $list */
|
||||
$lists->top();
|
||||
while ($lists->valid()) {
|
||||
try {
|
||||
$listener($event);
|
||||
call_user_func($lists->current(), $event);
|
||||
} catch (\Throwable $exception) {
|
||||
$this->logger->error($exception->getMessage(), [$exception]);
|
||||
}
|
||||
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
|
||||
break;
|
||||
}
|
||||
$lists->next();
|
||||
}
|
||||
return $event;
|
||||
}
|
||||
|
||||
+5
-3
@@ -4,6 +4,7 @@ namespace Kiri\Events;
|
||||
|
||||
|
||||
use Psr\EventDispatcher\ListenerProviderInterface;
|
||||
use SplPriorityQueue;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -17,11 +18,12 @@ class EventProvider implements ListenerProviderInterface
|
||||
|
||||
/**
|
||||
* @param object $event
|
||||
* @return iterable
|
||||
* @return SplPriorityQueue
|
||||
*/
|
||||
public function getListenersForEvent(object $event): iterable
|
||||
public function getListenersForEvent(object $event): SplPriorityQueue
|
||||
{
|
||||
$queue = new \SplPriorityQueue();
|
||||
$queue = new SplPriorityQueue();
|
||||
$queue->setExtractFlags(SplPriorityQueue::EXTR_PRIORITY);
|
||||
// TODO: Implement getListenersForEvent() method.
|
||||
foreach ($this->_listeners[get_class($event)] ?? [] as $listener) {
|
||||
$queue->insert($listener->listener, $listener->priority);
|
||||
|
||||
Reference in New Issue
Block a user