Upgrade framework
This commit is contained in:
124
vendor/symfony/routing/Annotation/Route.php
vendored
124
vendor/symfony/routing/Annotation/Route.php
vendored
@@ -15,46 +15,68 @@ 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 $path;
|
||||
private $name;
|
||||
private $requirements = array();
|
||||
private $options = array();
|
||||
private $defaults = array();
|
||||
private $host;
|
||||
private $methods = array();
|
||||
private $schemes = array();
|
||||
private $condition;
|
||||
private ?string $path = null;
|
||||
private array $localizedPaths = [];
|
||||
private array $methods;
|
||||
private array $schemes;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param array $data An array of key/value parameters
|
||||
*
|
||||
* @throws \BadMethodCallException
|
||||
* @param string[] $requirements
|
||||
* @param string[]|string $methods
|
||||
* @param string[]|string $schemes
|
||||
*/
|
||||
public function __construct(array $data)
|
||||
{
|
||||
if (isset($data['value'])) {
|
||||
$data['path'] = $data['value'];
|
||||
unset($data['value']);
|
||||
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;
|
||||
}
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$method = 'set'.str_replace('_', '', $key);
|
||||
if (!method_exists($this, $method)) {
|
||||
throw new \BadMethodCallException(sprintf('Unknown property "%s" on annotation "%s".', $key, get_class($this)));
|
||||
}
|
||||
$this->$method($value);
|
||||
if (null !== $format) {
|
||||
$this->defaults['_format'] = $format;
|
||||
}
|
||||
|
||||
if (null !== $utf8) {
|
||||
$this->options['utf8'] = $utf8;
|
||||
}
|
||||
|
||||
if (null !== $stateless) {
|
||||
$this->defaults['_stateless'] = $stateless;
|
||||
}
|
||||
}
|
||||
|
||||
public function setPath($path)
|
||||
public function setPath(string $path)
|
||||
{
|
||||
$this->path = $path;
|
||||
}
|
||||
@@ -64,7 +86,17 @@ class Route
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
public function setHost($pattern)
|
||||
public function setLocalizedPaths(array $localizedPaths)
|
||||
{
|
||||
$this->localizedPaths = $localizedPaths;
|
||||
}
|
||||
|
||||
public function getLocalizedPaths(): array
|
||||
{
|
||||
return $this->localizedPaths;
|
||||
}
|
||||
|
||||
public function setHost(string $pattern)
|
||||
{
|
||||
$this->host = $pattern;
|
||||
}
|
||||
@@ -74,7 +106,7 @@ class Route
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
@@ -84,7 +116,7 @@ class Route
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setRequirements($requirements)
|
||||
public function setRequirements(array $requirements)
|
||||
{
|
||||
$this->requirements = $requirements;
|
||||
}
|
||||
@@ -94,7 +126,7 @@ class Route
|
||||
return $this->requirements;
|
||||
}
|
||||
|
||||
public function setOptions($options)
|
||||
public function setOptions(array $options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
@@ -104,7 +136,7 @@ class Route
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
public function setDefaults($defaults)
|
||||
public function setDefaults(array $defaults)
|
||||
{
|
||||
$this->defaults = $defaults;
|
||||
}
|
||||
@@ -114,9 +146,9 @@ class Route
|
||||
return $this->defaults;
|
||||
}
|
||||
|
||||
public function setSchemes($schemes)
|
||||
public function setSchemes(array|string $schemes)
|
||||
{
|
||||
$this->schemes = is_array($schemes) ? $schemes : array($schemes);
|
||||
$this->schemes = (array) $schemes;
|
||||
}
|
||||
|
||||
public function getSchemes()
|
||||
@@ -124,9 +156,9 @@ class Route
|
||||
return $this->schemes;
|
||||
}
|
||||
|
||||
public function setMethods($methods)
|
||||
public function setMethods(array|string $methods)
|
||||
{
|
||||
$this->methods = is_array($methods) ? $methods : array($methods);
|
||||
$this->methods = (array) $methods;
|
||||
}
|
||||
|
||||
public function getMethods()
|
||||
@@ -134,7 +166,7 @@ class Route
|
||||
return $this->methods;
|
||||
}
|
||||
|
||||
public function setCondition($condition)
|
||||
public function setCondition(?string $condition)
|
||||
{
|
||||
$this->condition = $condition;
|
||||
}
|
||||
@@ -143,4 +175,24 @@ class Route
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user