2 Commits

Author SHA1 Message Date
as2252258 100ce506ea modify plugin name 2022-03-03 18:30:59 +08:00
as2252258 a4c50f975e modify plugin name 2022-02-23 16:32:08 +08:00
+17 -3
View File
@@ -2,8 +2,10 @@
namespace Kiri\Events; namespace Kiri\Events;
use Kiri\Abstracts\Component;
use Kiri; use Kiri;
use Kiri\Abstracts\Component;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\EventDispatcher\StoppableEventInterface; use Psr\EventDispatcher\StoppableEventInterface;
@@ -15,14 +17,26 @@ 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 * @param object $event
* @return object * @return object
* @throws \ReflectionException * @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/ */
public function dispatch(object $event): object public function dispatch(object $event): object
{ {
$lists = $this->getEventProvider()->getListenersForEvent($event); $lists = $this->eventProvider->getListenersForEvent($event);
foreach ($lists as $listener) { foreach ($lists as $listener) {
/** @var Struct $list */ /** @var Struct $list */
$listener($event); $listener($event);