Files
kiri-core/note/Asynchronous.php
T
2021-09-18 16:54:39 +08:00

44 lines
612 B
PHP

<?php
namespace Annotation;
use Exception;
use Kiri\Kiri;
/**
* Class Asynchronous
* @package Annotation
* Task任务
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Asynchronous extends Attribute
{
/**
* Asynchronous constructor.
* @param string $name
*/
public function __construct(public string $name)
{
}
/**
* @param mixed $class
* @param mixed|null $method
* @return bool
* @throws Exception
*/
public function execute(mixed $class, mixed $method = null): bool
{
$async = Kiri::app()->getAsync();
$async->addAsync($this->name, $class);
return true;
}
}