Files
kiri-core/Annotation/Event.php
T

45 lines
746 B
PHP
Raw Normal View History

2021-02-09 11:13:43 +08:00
<?php
namespace Annotation;
2021-02-22 17:44:24 +08:00
use Exception;
2021-02-09 11:13:43 +08:00
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake;
/**
* Class Event
* @package Annotation
*/
2021-02-22 17:44:24 +08:00
#[\Attribute(\Attribute::TARGET_METHOD)] class Event implements IAnnotation
2021-02-09 11:13:43 +08:00
{
/**
* Event constructor.
* @param string $name
* @param array $params
*/
public function __construct(public string $name, public array $params = [])
{
2021-02-22 17:44:24 +08:00
}
/**
* @param array $handler
* @return \Snowflake\Event
* @throws ComponentException
* @throws Exception
*/
public function execute(array $handler): \Snowflake\Event
{
// TODO: Implement execute() method.
2021-02-09 11:13:43 +08:00
$event = Snowflake::app()->getEvent();
2021-02-22 17:44:24 +08:00
$event->on($this->name, $handler, $this->params);
return $event;
2021-02-09 11:13:43 +08:00
}
}