RouteCollection
in package
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.
Tags
Interfaces, Classes, Traits and Enums
- IteratorAggregate
- Countable
Table of Contents
- $resources : array<string|int, mixed>
- $routes : array<string|int, Route>
- __clone() : mixed
- add() : mixed
- addCollection() : mixed
- Adds a route collection at the end of the current set by appending all routes of the added collection.
- addDefaults() : mixed
- Adds defaults to all routes.
- addNamePrefix() : mixed
- Adds a prefix to the name of all the routes within in the collection.
- addOptions() : mixed
- Adds options to all routes.
- addPrefix() : mixed
- Adds a prefix to the path of all child routes.
- addRequirements() : mixed
- Adds requirements to all routes.
- addResource() : mixed
- Adds a resource for this collection. If the resource already exists it is not added.
- all() : array<string|int, Route>
- Returns all routes in this collection.
- count() : int
- Gets the number of Routes in this collection.
- get() : Route|null
- Gets a route by name.
- getIterator() : ArrayIterator|array<string|int, Route>
- Gets the current RouteCollection as an Iterator that includes all routes.
- getResources() : array<string|int, ResourceInterface>
- Returns an array of resources loaded to build this collection.
- remove() : mixed
- Removes a route or an array of routes by name from the collection.
- setCondition() : mixed
- Sets a condition on all routes.
- setHost() : mixed
- Sets the host pattern on all routes.
- setMethods() : mixed
- Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.
- setSchemes() : mixed
- Sets the schemes (e.g. 'https') all child routes are restricted to.
Properties
$resources
private
array<string|int, mixed>
$resources
= []
$routes
private
array<string|int, Route>
$routes
= []
Methods
__clone()
public
__clone() : mixed
Return values
mixed —add()
public
add(string $name, Route $route) : mixed
Parameters
- $name : string
- $route : Route
Return values
mixed —addCollection()
Adds a route collection at the end of the current set by appending all routes of the added collection.
public
addCollection(self $collection) : mixed
Parameters
- $collection : self
Return values
mixed —addDefaults()
Adds defaults to all routes.
public
addDefaults(array<string|int, mixed> $defaults) : mixed
An existing default value under the same name in a route will be overridden.
Parameters
- $defaults : array<string|int, mixed>
Return values
mixed —addNamePrefix()
Adds a prefix to the name of all the routes within in the collection.
public
addNamePrefix(string $prefix) : mixed
Parameters
- $prefix : string
Return values
mixed —addOptions()
Adds options to all routes.
public
addOptions(array<string|int, mixed> $options) : mixed
An existing option value under the same name in a route will be overridden.
Parameters
- $options : array<string|int, mixed>
Return values
mixed —addPrefix()
Adds a prefix to the path of all child routes.
public
addPrefix(string $prefix[, array<string|int, mixed> $defaults = [] ][, array<string|int, mixed> $requirements = [] ]) : mixed
Parameters
- $prefix : string
- $defaults : array<string|int, mixed> = []
- $requirements : array<string|int, mixed> = []
Return values
mixed —addRequirements()
Adds requirements to all routes.
public
addRequirements(array<string|int, mixed> $requirements) : mixed
An existing requirement under the same name in a route will be overridden.
Parameters
- $requirements : array<string|int, mixed>
Return values
mixed —addResource()
Adds a resource for this collection. If the resource already exists it is not added.
public
addResource(ResourceInterface $resource) : mixed
Parameters
- $resource : ResourceInterface
Return values
mixed —all()
Returns all routes in this collection.
public
all() : array<string|int, Route>
Return values
array<string|int, Route> —An array of routes
count()
Gets the number of Routes in this collection.
public
count() : int
Return values
int —The number of routes
get()
Gets a route by name.
public
get(string $name) : Route|null
Parameters
- $name : string
Return values
Route|null —A Route instance or null when not found
getIterator()
Gets the current RouteCollection as an Iterator that includes all routes.
public
getIterator() : ArrayIterator|array<string|int, Route>
It implements \IteratorAggregate.
Tags
Return values
ArrayIterator|array<string|int, Route> —An \ArrayIterator object for iterating over routes
getResources()
Returns an array of resources loaded to build this collection.
public
getResources() : array<string|int, ResourceInterface>
Return values
array<string|int, ResourceInterface> —An array of resources
remove()
Removes a route or an array of routes by name from the collection.
public
remove(string|array<string|int, string> $name) : mixed
Parameters
- $name : string|array<string|int, string>
-
The route name or an array of route names
Return values
mixed —setCondition()
Sets a condition on all routes.
public
setCondition(string|null $condition) : mixed
Existing conditions will be overridden.
Parameters
- $condition : string|null
Return values
mixed —setHost()
Sets the host pattern on all routes.
public
setHost(string|null $pattern[, array<string|int, mixed> $defaults = [] ][, array<string|int, mixed> $requirements = [] ]) : mixed
Parameters
- $pattern : string|null
- $defaults : array<string|int, mixed> = []
- $requirements : array<string|int, mixed> = []
Return values
mixed —setMethods()
Sets the HTTP methods (e.g. 'POST') all child routes are restricted to.
public
setMethods(string|array<string|int, string> $methods) : mixed
Parameters
- $methods : string|array<string|int, string>
-
The method or an array of methods
Return values
mixed —setSchemes()
Sets the schemes (e.g. 'https') all child routes are restricted to.
public
setSchemes(string|array<string|int, string> $schemes) : mixed
Parameters
- $schemes : string|array<string|int, string>
-
The scheme or an array of schemes