2 Commits

Author SHA1 Message Date
as2252258 a44cfb70b1 modify mysql result 2022-04-29 16:43:54 +08:00
as2252258 100ce506ea modify plugin name 2022-03-03 18:30:59 +08:00
+17 -2
View File
@@ -2,8 +2,8 @@
namespace Kiri\Events;
use Kiri\Abstracts\Component;
use Kiri;
use Kiri\Abstracts\Component;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\EventDispatcher\EventDispatcherInterface;
@@ -17,6 +17,17 @@ class EventDispatch extends Component implements EventDispatcherInterface
{
/**
* @param EventProvider $eventProvider
* @param array $config
* @throws \Exception
*/
public function __construct(public EventProvider $eventProvider, array $config = [])
{
parent::__construct($config);
}
/**
* @param object $event
* @return object
@@ -25,10 +36,14 @@ class EventDispatch extends Component implements EventDispatcherInterface
*/
public function dispatch(object $event): object
{
$lists = $this->getEventProvider()->getListenersForEvent($event);
$lists = $this->eventProvider->getListenersForEvent($event);
foreach ($lists as $listener) {
/** @var Struct $list */
try {
$listener($event);
}catch (\Throwable $exception) {
$this->logger->addError($exception);
}
if ($event instanceof StoppableEventInterface && $event->isPropagationStopped()) {
break;
}