eee
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Kiri\Events;
|
||||||
|
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Kiri\Di\Interface\InjectTargetInterface;
|
||||||
|
|
||||||
|
#[\Attribute]
|
||||||
|
readonly class EventListener implements InjectTargetInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $event
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function __construct(public string $event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $class
|
||||||
|
* @return void
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function dispatch(string $class): void
|
||||||
|
{
|
||||||
|
// TODO: Implement dispatch() method.
|
||||||
|
$target = \Kiri::getDi()->getReflectionClass($class)->newInstanceWithoutConstructor();
|
||||||
|
|
||||||
|
on($this->event, [$target, "onHandler"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user