199 lines
4.1 KiB
PHP
199 lines
4.1 KiB
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
* This file is part of the Symfony package.
|
||
|
*
|
||
|
* (c) Fabien Potencier <fabien@symfony.com>
|
||
|
*
|
||
|
* For the full copyright and license information, please view the LICENSE
|
||
|
* file that was distributed with this source code.
|
||
|
*/
|
||
|
|
||
|
namespace Symfony\Component\Routing\Annotation;
|
||
|
|
||
|
/**
|
||
|
* Annotation class for @Route().
|
||
|
*
|
||
|
* @Annotation
|
||
|
* @NamedArgumentConstructor
|
||
|
* @Target({"CLASS", "METHOD"})
|
||
|
*
|
||
|
* @author Fabien Potencier <fabien@symfony.com>
|
||
|
* @author Alexander M. Turek <me@derrabus.de>
|
||
|
*/
|
||
|
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
|
||
|
class Route
|
||
|
{
|
||
|
private ?string $path = null;
|
||
|
private array $localizedPaths = [];
|
||
|
private array $methods;
|
||
|
private array $schemes;
|
||
|
|
||
|
/**
|
||
|
* @param array<string|\Stringable> $requirements
|
||
|
* @param string[]|string $methods
|
||
|
* @param string[]|string $schemes
|
||
|
*/
|
||
|
public function __construct(
|
||
|
string|array $path = null,
|
||
|
private ?string $name = null,
|
||
|
private array $requirements = [],
|
||
|
private array $options = [],
|
||
|
private array $defaults = [],
|
||
|
private ?string $host = null,
|
||
|
array|string $methods = [],
|
||
|
array|string $schemes = [],
|
||
|
private ?string $condition = null,
|
||
|
private ?int $priority = null,
|
||
|
string $locale = null,
|
||
|
string $format = null,
|
||
|
bool $utf8 = null,
|
||
|
bool $stateless = null,
|
||
|
private ?string $env = null
|
||
|
) {
|
||
|
if (\is_array($path)) {
|
||
|
$this->localizedPaths = $path;
|
||
|
} else {
|
||
|
$this->path = $path;
|
||
|
}
|
||
|
$this->setMethods($methods);
|
||
|
$this->setSchemes($schemes);
|
||
|
|
||
|
if (null !== $locale) {
|
||
|
$this->defaults['_locale'] = $locale;
|
||
|
}
|
||
|
|
||
|
if (null !== $format) {
|
||
|
$this->defaults['_format'] = $format;
|
||
|
}
|
||
|
|
||
|
if (null !== $utf8) {
|
||
|
$this->options['utf8'] = $utf8;
|
||
|
}
|
||
|
|
||
|
if (null !== $stateless) {
|
||
|
$this->defaults['_stateless'] = $stateless;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public function setPath(string $path)
|
||
|
{
|
||
|
$this->path = $path;
|
||
|
}
|
||
|
|
||
|
public function getPath()
|
||
|
{
|
||
|
return $this->path;
|
||
|
}
|
||
|
|
||
|
public function setLocalizedPaths(array $localizedPaths)
|
||
|
{
|
||
|
$this->localizedPaths = $localizedPaths;
|
||
|
}
|
||
|
|
||
|
public function getLocalizedPaths(): array
|
||
|
{
|
||
|
return $this->localizedPaths;
|
||
|
}
|
||
|
|
||
|
public function setHost(string $pattern)
|
||
|
{
|
||
|
$this->host = $pattern;
|
||
|
}
|
||
|
|
||
|
public function getHost()
|
||
|
{
|
||
|
return $this->host;
|
||
|
}
|
||
|
|
||
|
public function setName(string $name)
|
||
|
{
|
||
|
$this->name = $name;
|
||
|
}
|
||
|
|
||
|
public function getName()
|
||
|
{
|
||
|
return $this->name;
|
||
|
}
|
||
|
|
||
|
public function setRequirements(array $requirements)
|
||
|
{
|
||
|
$this->requirements = $requirements;
|
||
|
}
|
||
|
|
||
|
public function getRequirements()
|
||
|
{
|
||
|
return $this->requirements;
|
||
|
}
|
||
|
|
||
|
public function setOptions(array $options)
|
||
|
{
|
||
|
$this->options = $options;
|
||
|
}
|
||
|
|
||
|
public function getOptions()
|
||
|
{
|
||
|
return $this->options;
|
||
|
}
|
||
|
|
||
|
public function setDefaults(array $defaults)
|
||
|
{
|
||
|
$this->defaults = $defaults;
|
||
|
}
|
||
|
|
||
|
public function getDefaults()
|
||
|
{
|
||
|
return $this->defaults;
|
||
|
}
|
||
|
|
||
|
public function setSchemes(array|string $schemes)
|
||
|
{
|
||
|
$this->schemes = (array) $schemes;
|
||
|
}
|
||
|
|
||
|
public function getSchemes()
|
||
|
{
|
||
|
return $this->schemes;
|
||
|
}
|
||
|
|
||
|
public function setMethods(array|string $methods)
|
||
|
{
|
||
|
$this->methods = (array) $methods;
|
||
|
}
|
||
|
|
||
|
public function getMethods()
|
||
|
{
|
||
|
return $this->methods;
|
||
|
}
|
||
|
|
||
|
public function setCondition(?string $condition)
|
||
|
{
|
||
|
$this->condition = $condition;
|
||
|
}
|
||
|
|
||
|
public function getCondition()
|
||
|
{
|
||
|
return $this->condition;
|
||
|
}
|
||
|
|
||
|
public function setPriority(int $priority): void
|
||
|
{
|
||
|
$this->priority = $priority;
|
||
|
}
|
||
|
|
||
|
public function getPriority(): ?int
|
||
|
{
|
||
|
return $this->priority;
|
||
|
}
|
||
|
|
||
|
public function setEnv(?string $env): void
|
||
|
{
|
||
|
$this->env = $env;
|
||
|
}
|
||
|
|
||
|
public function getEnv(): ?string
|
||
|
{
|
||
|
return $this->env;
|
||
|
}
|
||
|
}
|