97cd1a0ebf
This reverts commit fdf58326
45 lines
642 B
PHP
45 lines
642 B
PHP
<?php
|
|
|
|
|
|
namespace Kiri\Annotation;
|
|
|
|
|
|
use Exception;
|
|
use Kiri\Kiri;
|
|
use Server\Tasker\AsyncTaskExecute;
|
|
|
|
|
|
/**
|
|
* Class Task
|
|
* @package Annotation
|
|
* Task任务
|
|
*/
|
|
#[\Attribute(\Attribute::TARGET_CLASS)] class Task extends Attribute
|
|
{
|
|
|
|
|
|
/**
|
|
* Task 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
|
|
{
|
|
$task = Kiri::getDi()->get(AsyncTaskExecute::class);
|
|
$task->reg($this->name, $class);
|
|
return true;
|
|
}
|
|
|
|
}
|