This commit is contained in:
2023-10-17 21:18:52 +08:00
parent ca5ce86ee3
commit 04d2d3094b
+13 -2
View File
@@ -11,6 +11,7 @@ use Psr\Container\NotFoundExceptionInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\EventDispatcher\StoppableEventInterface;
use ReflectionException;
use SplPriorityQueue;
/**
@@ -23,12 +24,22 @@ class EventDispatch extends Component implements EventDispatcherInterface
/**
* @param object $event
* @return object
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface|ReflectionException
*/
public function dispatch(object $event): object
{
$lists = make(EventProvider::class)->getListenersForEvent($event);
return $this->execute($lists, $event);
}
/**
* @param SplPriorityQueue $lists
* @param object $event
* @return object
*/
public function execute(SplPriorityQueue $lists, object $event): object
{
if ($lists->isEmpty()) {
return $event;
}