32 lines
646 B
PHP
32 lines
646 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Kiri\Router\Annotate;
|
|
|
|
use Kiri\Di\Interface\InjectMethodInterface;
|
|
|
|
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
|
class Defer implements InjectMethodInterface
|
|
{
|
|
|
|
/**
|
|
* @param string|array $callback Class name or [Class::class, 'method']
|
|
* @param array $params
|
|
*/
|
|
public function __construct(readonly public string|array $callback, readonly public array $params = [])
|
|
{
|
|
}
|
|
|
|
|
|
/**
|
|
* @param string $class
|
|
* @param string $method
|
|
* @return void
|
|
*/
|
|
public function dispatch(string $class, string $method): void
|
|
{
|
|
DeferRegistry::add($class, $method, $this);
|
|
}
|
|
|
|
}
|