Files
kiri-router/src/Inject/Get.php
T

33 lines
730 B
PHP
Raw Normal View History

2023-04-15 23:29:27 +08:00
<?php
2023-04-15 23:31:16 +08:00
namespace Kiri\Router\Inject;
2023-04-15 23:29:27 +08:00
2023-04-15 23:31:16 +08:00
use Exception;
2023-04-15 23:29:27 +08:00
use Kiri\Annotation\Route\RequestMethod;
2023-04-15 23:31:16 +08:00
use Kiri\Router\InjectRouteInterface;
use Kiri\Router\Router;
use ReflectionException;
2023-04-15 23:29:27 +08:00
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
class Get extends AbstractRequestMethod implements InjectRouteInterface
{
/**
* @param object $class
* @param string $method
* @return void
2023-04-15 23:31:16 +08:00
* @throws ReflectionException
* @throws Exception
* @throws ReflectionException
2023-04-15 23:29:27 +08:00
*/
public function dispatch(object $class, string $method): void
{
// TODO: Implement dispatch() method.
Router::addRoute(RequestMethod::REQUEST_GET, $this->path, [$class, $method]);
2023-04-15 23:31:16 +08:00
$this->registerMiddleware($class, $method);
2023-04-15 23:29:27 +08:00
}
}