2020-03-02 16:14:20 +08:00
|
|
|
<?php
|
|
|
|
|
|
2022-03-15 18:05:33 +08:00
|
|
|
declare(strict_types=1);
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
namespace ZM\Annotation\Http;
|
|
|
|
|
|
2022-03-20 01:53:36 +08:00
|
|
|
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
|
2020-03-02 16:14:20 +08:00
|
|
|
use Doctrine\Common\Annotations\Annotation\Required;
|
|
|
|
|
use Doctrine\Common\Annotations\Annotation\Target;
|
|
|
|
|
use ZM\Annotation\AnnotationBase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class RequestMapping
|
|
|
|
|
* @Annotation
|
2022-03-20 01:53:36 +08:00
|
|
|
* @NamedArgumentConstructor()
|
2020-08-31 10:11:06 +08:00
|
|
|
* @Target("METHOD")
|
2020-03-02 16:14:20 +08:00
|
|
|
*/
|
2022-11-03 10:18:17 +08:00
|
|
|
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
|
2022-08-01 16:31:54 +08:00
|
|
|
class Route extends AnnotationBase
|
2020-03-02 16:14:20 +08:00
|
|
|
{
|
2022-12-19 20:22:47 +08:00
|
|
|
public function __construct(
|
|
|
|
|
/**
|
|
|
|
|
* @Required()
|
|
|
|
|
*/
|
|
|
|
|
public $route,
|
|
|
|
|
public $name = '',
|
|
|
|
|
public $request_method = ['GET', 'POST'],
|
|
|
|
|
/**
|
|
|
|
|
* Routing path params binding. eg. {"id"="\d+"}
|
|
|
|
|
*/
|
|
|
|
|
public $params = []
|
2024-10-02 20:31:16 +08:00
|
|
|
) {}
|
2022-08-13 17:00:29 +08:00
|
|
|
|
2022-12-18 00:17:28 +08:00
|
|
|
public static function make($route, $name = '', $request_method = ['GET', 'POST'], $params = []): static
|
2022-08-13 17:00:29 +08:00
|
|
|
{
|
|
|
|
|
return new static($route, $name, $request_method, $params);
|
|
|
|
|
}
|
2020-08-31 10:11:06 +08:00
|
|
|
}
|