Files
kiri-core/note/Asynchronous.php
T

45 lines
655 B
PHP
Raw Normal View History

2021-03-24 17:02:12 +08:00
<?php
namespace Annotation;
use Exception;
2021-08-17 16:43:50 +08:00
use Http\IInterface\Task;
2021-08-11 01:04:57 +08:00
use Kiri\Kiri;
2021-03-24 17:02:12 +08:00
/**
* Class Asynchronous
* @package Annotation
* Task任务
*/
#[\Attribute(\Attribute::TARGET_CLASS)] class Asynchronous extends Attribute
{
/**
* Asynchronous constructor.
* @param string $name
*/
2021-08-29 04:06:49 +08:00
public function __construct(string $name)
2021-03-24 17:02:12 +08:00
{
}
/**
2021-07-12 17:17:36 +08:00
* @param mixed $class
* @param mixed|null $method
2021-03-24 17:02:12 +08:00
* @return bool
* @throws Exception
*/
2021-08-29 04:06:49 +08:00
public static function execute(mixed $params, mixed $class, mixed $method = null): bool
2021-07-12 17:17:36 +08:00
{
2021-08-11 01:04:57 +08:00
$async = Kiri::app()->getAsync();
2021-08-29 04:06:49 +08:00
$async->addAsync($params->name, $class);
2021-03-24 17:02:12 +08:00
return true;
}
}