Files
kiri-core/Annotation/Event.php
T
as2252258@163.com 682246df28 modify
2021-08-11 01:04:57 +08:00

45 lines
702 B
PHP

<?php
namespace Annotation;
use Exception;
use Kiri\Exception\ComponentException;
use Kiri\Kiri;
use Kiri\Event as SEvent;
/**
* 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
{
// TODO: Implement execute() method.
SEvent::on($this->name, [$class, $method]);
return true;
}
}