Revert "改名"

This reverts commit fdf58326
This commit is contained in:
2022-01-08 18:49:08 +08:00
parent 7165a67294
commit 97cd1a0ebf
33 changed files with 169 additions and 172 deletions
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Kiri\Annotation;
use Exception;
use Kiri\Events\EventProvider;
use Kiri\Kiri;
/**
* Class Event
* @package Annotation
*/
#[\Attribute(\Attribute::TARGET_METHOD)] class Event extends Attribute
{
/**
* Event constructor.
* @param string $name
* @param array $params
*/
public function __construct(public string $name, public array $params = [])
{
}
/**
* @param mixed $class
* @param mixed|null $method
* @return bool
* @throws Exception
*/
public function execute(mixed $class, mixed $method = null): bool
{
$pro = Kiri::getDi()->get(EventProvider::class);
if (is_string($class)) {
$class = Kiri::getDi()->get($class);
}
$pro->on($this->name, [$class, $method]);
return true;
}
}