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.
Methods
| __clone() | ||
| ArrayIterator |
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|array $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. |
||
|
setHost(string $pattern, array $defaults = array(), array $requirements = array())
Sets the host pattern 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|array $schemes)
Sets the schemes (e.g. |
||
|
setMethods(string|array $methods)
Sets the HTTP methods (e.g. |
||
| ResourceInterface[] |
getResources()
Returns an array of resources loaded to build this collection. |
|
|
addResource(ResourceInterface $resource)
Adds a resource for this collection. |
Details
at line 40
public
__clone()
at line 56
public ArrayIterator
getIterator()
Gets the current RouteCollection as an Iterator that includes all routes.
It implements \IteratorAggregate.
at line 66
public int
count()
Gets the number of Routes in this collection.
at line 79
public
add(string $name, Route $route)
Adds a route.
at line 91
public Route[]
all()
Returns all routes in this collection.
at line 103
public Route|null
get(string $name)
Gets a route by name.
at line 113
public
remove(string|array $name)
Removes a route or an array of routes by name from the collection
at line 128
public
addCollection(RouteCollection $collection)
Adds a route collection at the end of the current set by appending all routes of the added collection.
at line 149
public
addPrefix(string $prefix, array $defaults = array(), array $requirements = array())
Adds a prefix to the path of all child routes.
at line 171
public
setHost(string $pattern, array $defaults = array(), array $requirements = array())
Sets the host pattern on all routes.
at line 187
public
addDefaults(array $defaults)
Adds defaults to all routes.
An existing default value under the same name in a route will be overridden.
at line 203
public
addRequirements(array $requirements)
Adds requirements to all routes.
An existing requirement under the same name in a route will be overridden.
at line 219
public
addOptions(array $options)
Adds options to all routes.
An existing option value under the same name in a route will be overridden.
at line 233
public
setSchemes(string|array $schemes)
Sets the schemes (e.g.
'https') all child routes are restricted to.
at line 245
public
setMethods(string|array $methods)
Sets the HTTP methods (e.g.
'POST') all child routes are restricted to.
at line 257
public ResourceInterface[]
getResources()
Returns an array of resources loaded to build this collection.
at line 267
public
addResource(ResourceInterface $resource)
Adds a resource for this collection.