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-12-18 21:55:44 +08:00
|
|
|
use Kiri;
|
2023-04-16 01:24:30 +08:00
|
|
|
use Kiri\Router\Constrict\RequestMethod;
|
2023-04-15 23:31:16 +08:00
|
|
|
use Kiri\Router\Router;
|
2023-12-18 22:23:17 +08:00
|
|
|
use Kiri\Di\Interface\InjectMethodInterface;
|
2023-04-15 23:29:27 +08:00
|
|
|
|
2023-12-18 22:23:17 +08:00
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
2023-04-15 23:29:27 +08:00
|
|
|
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
2023-12-18 22:23:17 +08:00
|
|
|
class Put extends AbstractRequestMethod implements InjectMethodInterface
|
2023-04-15 23:29:27 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
2023-07-25 10:09:06 +08:00
|
|
|
/**
|
|
|
|
|
* @param string $path
|
|
|
|
|
* @param string $version
|
|
|
|
|
*/
|
2023-12-12 15:35:35 +08:00
|
|
|
public function __construct(readonly public string $path, readonly public string $version = '')
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2023-12-18 22:23:17 +08:00
|
|
|
* @param string $class
|
2023-12-12 15:35:35 +08:00
|
|
|
* @param string $method
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2023-12-18 22:23:17 +08:00
|
|
|
public function dispatch(string $class, string $method): void
|
2023-12-12 15:35:35 +08:00
|
|
|
{
|
|
|
|
|
// TODO: Implement dispatch() method.
|
|
|
|
|
$path = '/' . ltrim($this->path, '/');
|
2023-11-14 00:09:52 +08:00
|
|
|
if (!empty($this->version)) {
|
|
|
|
|
$path = '/' . trim($this->version) . $path;
|
|
|
|
|
}
|
2024-08-29 15:56:30 +08:00
|
|
|
Router::addRoute(RequestMethod::REQUEST_PUT, $path, [$class, $method]);
|
2023-12-12 15:35:35 +08:00
|
|
|
}
|
2023-04-15 23:29:27 +08:00
|
|
|
|
|
|
|
|
}
|