trait AddTrait
@author Nicolas Grekas <p@tchwork.com>
Hierarchy
- trait \Symfony\Component\Routing\Loader\Configurator\Traits\AddTrait uses \Symfony\Component\Routing\Loader\Configurator\Traits\LocalizedRouteTrait
File
-
vendor/
symfony/ routing/ Loader/ Configurator/ Traits/ AddTrait.php, line 22
Namespace
Symfony\Component\Routing\Loader\Configurator\TraitsView source
trait AddTrait {
use LocalizedRouteTrait;
protected RouteCollection $collection;
protected string $name = '';
protected ?array $prefixes = null;
/**
* Adds a route.
*
* @param string|array $path the path, or the localized paths of the route
*/
public function add(string $name, string|array $path) : RouteConfigurator {
$parentConfigurator = $this instanceof CollectionConfigurator ? $this : ($this instanceof RouteConfigurator ? $this->parentConfigurator : null);
$route = $this->createLocalizedRoute($this->collection, $name, $path, $this->name, $this->prefixes);
return new RouteConfigurator($this->collection, $route, $this->name, $parentConfigurator, $this->prefixes);
}
public function alias(string $name, string $alias) : AliasConfigurator {
return new AliasConfigurator($this->collection
->addAlias($name, $alias));
}
/**
* Adds a route.
*
* @param string|array $path the path, or the localized paths of the route
*/
public function __invoke(string $name, string|array $path) : RouteConfigurator {
return $this->add($name, $path);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
AddTrait::$collection | protected | property | |
AddTrait::$name | protected | property | |
AddTrait::$prefixes | protected | property | |
AddTrait::add | public | function | Adds a route. |
AddTrait::alias | public | function | |
AddTrait::__invoke | public | function | Adds a route. |
LocalizedRouteTrait::createLocalizedRoute | final protected | function | Creates one or many routes. |
LocalizedRouteTrait::createRoute | private | function |