2023-04-15 23:29:27 +08:00
|
|
|
<?php
|
2023-04-16 01:24:30 +08:00
|
|
|
declare(strict_types=1);
|
2023-04-15 23:29:27 +08:00
|
|
|
|
2023-04-16 20:36:47 +08:00
|
|
|
namespace Kiri\Router\Annotate;
|
2023-04-15 23:29:27 +08:00
|
|
|
|
2023-04-15 23:31:16 +08:00
|
|
|
use Exception;
|
2023-04-16 01:24:30 +08:00
|
|
|
use Kiri\Router\Constrict\RequestMethod;
|
2023-04-16 23:08:57 +08:00
|
|
|
use Kiri\Router\Interface\InjectRouteInterface;
|
2023-08-02 14:00:25 +08:00
|
|
|
use Kiri\Router\OptionsController;
|
2023-04-15 23:31:16 +08:00
|
|
|
use Kiri\Router\Router;
|
|
|
|
|
use ReflectionException;
|
2023-04-15 23:29:27 +08:00
|
|
|
|
|
|
|
|
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
|
|
|
|
class Put extends AbstractRequestMethod implements InjectRouteInterface
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2023-07-25 10:09:06 +08:00
|
|
|
/**
|
|
|
|
|
* @param string $path
|
|
|
|
|
* @param string $version
|
2023-08-02 14:00:25 +08:00
|
|
|
* @param bool $enableOption
|
2023-07-25 10:09:06 +08:00
|
|
|
*/
|
2023-08-25 11:11:16 +08:00
|
|
|
public function __construct(readonly public string $path, readonly public string $version = 'v1')
|
2023-04-16 21:00:58 +08:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-04-15 23:29:27 +08:00
|
|
|
/**
|
|
|
|
|
* @param object $class
|
|
|
|
|
* @param string $method
|
|
|
|
|
* @return void
|
2023-04-15 23:31:16 +08:00
|
|
|
* @throws ReflectionException
|
|
|
|
|
* @throws Exception
|
2023-04-15 23:29:27 +08:00
|
|
|
*/
|
|
|
|
|
public function dispatch(object $class, string $method): void
|
|
|
|
|
{
|
|
|
|
|
// TODO: Implement dispatch() method.
|
2023-04-25 17:22:37 +08:00
|
|
|
$path = '/' . ltrim($this->path, '/');
|
2023-04-19 12:35:39 +08:00
|
|
|
|
|
|
|
|
Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$class, $method]);
|
2023-04-15 23:29:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|