| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <?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\Attribute;
- /**
- * 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|null $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;
- }
- }
- /**
- * @return void
- */
- public function setPath(string $path)
- {
- $this->path = $path;
- }
- /**
- * @return string|null
- */
- public function getPath()
- {
- return $this->path;
- }
- /**
- * @return void
- */
- public function setLocalizedPaths(array $localizedPaths)
- {
- $this->localizedPaths = $localizedPaths;
- }
- public function getLocalizedPaths(): array
- {
- return $this->localizedPaths;
- }
- /**
- * @return void
- */
- public function setHost(string $pattern)
- {
- $this->host = $pattern;
- }
- /**
- * @return string|null
- */
- public function getHost()
- {
- return $this->host;
- }
- /**
- * @return void
- */
- public function setName(string $name)
- {
- $this->name = $name;
- }
- /**
- * @return string|null
- */
- public function getName()
- {
- return $this->name;
- }
- /**
- * @return void
- */
- public function setRequirements(array $requirements)
- {
- $this->requirements = $requirements;
- }
- /**
- * @return array
- */
- public function getRequirements()
- {
- return $this->requirements;
- }
- /**
- * @return void
- */
- public function setOptions(array $options)
- {
- $this->options = $options;
- }
- /**
- * @return array
- */
- public function getOptions()
- {
- return $this->options;
- }
- /**
- * @return void
- */
- public function setDefaults(array $defaults)
- {
- $this->defaults = $defaults;
- }
- /**
- * @return array
- */
- public function getDefaults()
- {
- return $this->defaults;
- }
- /**
- * @return void
- */
- public function setSchemes(array|string $schemes)
- {
- $this->schemes = (array) $schemes;
- }
- /**
- * @return array
- */
- public function getSchemes()
- {
- return $this->schemes;
- }
- /**
- * @return void
- */
- public function setMethods(array|string $methods)
- {
- $this->methods = (array) $methods;
- }
- /**
- * @return array
- */
- public function getMethods()
- {
- return $this->methods;
- }
- /**
- * @return void
- */
- public function setCondition(?string $condition)
- {
- $this->condition = $condition;
- }
- /**
- * @return string|null
- */
- 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;
- }
- }
- if (!class_exists(\Symfony\Component\Routing\Annotation\Route::class, false)) {
- class_alias(Route::class, \Symfony\Component\Routing\Annotation\Route::class);
- }
|