class RouteCollection implements IteratorAggregate, Countable
A RouteCollection represents a set of Route instances.
When adding a route at the end of the collection, an existing route with the same name is removed first. So there can only be one route with a given name.
__clone() | ||
ArrayIterator|Route[] | getIterator() Gets the current RouteCollection as an Iterator that includes all routes. | |
int | count() Gets the number of Routes in this collection. | |
add(string $name, Route $route) Adds a route. | ||
Route[] | all() Returns all routes in this collection. | |
Route|null | get(string $name) Gets a route by name. | |
remove(string|string[] $name) Removes a route or an array of routes by name from the collection. | ||
addCollection(RouteCollection $collection) Adds a route collection at the end of the current set by appending all routes of the added collection. | ||
addPrefix(string $prefix, array $defaults = array(), array $requirements = array()) Adds a prefix to the path of all child routes. | ||
addNamePrefix(string $prefix) Adds a prefix to the name of all the routes within in the collection. | ||
setHost(string $pattern, array $defaults = array(), array $requirements = array()) Sets the host pattern on all routes. | ||
setCondition(string $condition) Sets a condition on all routes. | ||
addDefaults(array $defaults) Adds defaults to all routes. | ||
addRequirements(array $requirements) Adds requirements to all routes. | ||
addOptions(array $options) Adds options to all routes. | ||
setSchemes(string|string[] $schemes) Sets the schemes (e.g. 'https') all child routes are restricted to. | ||
setMethods(string|string[] $methods) Sets the HTTP methods (e.g. 'POST') all child routes are restricted to. | ||
ResourceInterface[] | getResources() Returns an array of resources loaded to build this collection. | |
addResource(ResourceInterface $resource) Adds a resource for this collection. If the resource already exists it is not added. |
Gets the current RouteCollection as an Iterator that includes all routes.
It implements \IteratorAggregate.
ArrayIterator|Route[] | An \ArrayIterator object for iterating over routes |
all() |
Gets the number of Routes in this collection.
int | The number of routes |
Adds a route.
string | $name | The route name |
Route | $route | A Route instance |
Returns all routes in this collection.
Route[] | An array of routes |
Gets a route by name.
string | $name | The route name |
Route|null | A Route instance or null when not found |
Removes a route or an array of routes by name from the collection.
string|string[] | $name | The route name or an array of route names |
Adds a route collection at the end of the current set by appending all routes of the added collection.
RouteCollection | $collection |
Adds a prefix to the path of all child routes.
string | $prefix | An optional prefix to add before each pattern of the route collection |
array | $defaults | An array of default values |
array | $requirements | An array of requirements |
Adds a prefix to the name of all the routes within in the collection.
string | $prefix |
Sets the host pattern on all routes.
string | $pattern | The pattern |
array | $defaults | An array of default values |
array | $requirements | An array of requirements |
Sets a condition on all routes.
Existing conditions will be overridden.
string | $condition | The condition |
Adds defaults to all routes.
An existing default value under the same name in a route will be overridden.
array | $defaults | An array of default values |
Adds requirements to all routes.
An existing requirement under the same name in a route will be overridden.
array | $requirements | An array of requirements |
Adds options to all routes.
An existing option value under the same name in a route will be overridden.
array | $options | An array of options |
Sets the schemes (e.g. 'https') all child routes are restricted to.
string|string[] | $schemes | The scheme or an array of schemes |
Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.
string|string[] | $methods | The method or an array of methods |
Returns an array of resources loaded to build this collection.
ResourceInterface[] | An array of resources |
Adds a resource for this collection. If the resource already exists it is not added.
ResourceInterface | $resource |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Routing/RouteCollection.html