57 lines
1.2 KiB
PHP
Raw Normal View History

2020-03-02 16:14:20 +08:00
<?php
declare(strict_types=1);
2020-03-02 16:14:20 +08:00
namespace ZM\Annotation\Http;
use Attribute;
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
* @NamedArgumentConstructor()
2020-08-31 10:11:06 +08:00
* @Target("METHOD")
2020-03-02 16:14:20 +08:00
*/
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Route extends AnnotationBase
2020-03-02 16:14:20 +08:00
{
/**
* @var string
* @Required()
*/
public $route = '';
/**
* @var string
*/
public $name = '';
/**
* @var array
*/
public $request_method = ['GET', 'POST'];
2020-03-02 16:14:20 +08:00
/**
* Routing path params binding. eg. {"id"="\d+"}
* @var array
*/
public $params = [];
public function __construct($route, $name = '', $request_method = ['GET', 'POST'], $params = [])
{
$this->route = $route;
$this->name = $name;
$this->request_method = $request_method;
$this->params = $params;
}
2022-08-13 17:00:29 +08:00
public static function make($route, $name = '', $request_method = ['GET', 'POST'], $params = [])
{
return new static($route, $name, $request_method, $params);
}
2020-08-31 10:11:06 +08:00
}