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 and Traits
- IteratorAggregate
- Countable
Table of Contents
- $aliases : array<string, Alias>
- $priorities : array<string, int>
- $resources : array<string, ResourceInterface>
- $routes : array<string, Route>
- __clone() : mixed
- add() : mixed
- addAlias() : Alias
- Sets an alias for an existing route.
- 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, 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.
- getAlias() : Alias|null
- getAliases() : array<string, Alias>
- getIterator() : ArrayIterator<string, Route>
- Gets the current RouteCollection as an Iterator that includes all routes.
- getPriority() : int|null
- 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
$aliases
private
array<string, Alias>
$aliases
= []
$priorities
private
array<string, int>
$priorities
= []
$resources
private
array<string, ResourceInterface>
$resources
= []
$routes
private
array<string, 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 —addAlias()
Sets an alias for an existing route.
public
addAlias(string $name, string $alias) : Alias
Parameters
- $name : string
-
The alias to create
- $alias : string
-
The route to alias
Tags
Return values
Alias —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, Route>
Return values
array<string, Route> —count()
Gets the number of Routes in this collection.
public
count() : int
Return values
int —get()
Gets a route by name.
public
get(string $name) : Route|null
Parameters
- $name : string
Return values
Route|null —getAlias()
public
getAlias(string $name) : Alias|null
Parameters
- $name : string
Return values
Alias|null —getAliases()
public
getAliases() : array<string, Alias>
Return values
array<string, Alias> —getIterator()
Gets the current RouteCollection as an Iterator that includes all routes.
public
getIterator() : ArrayIterator<string, Route>
It implements \IteratorAggregate.
Tags
Return values
ArrayIterator<string, Route> —getPriority()
public
getPriority(string $name) : int|null
Parameters
- $name : string
Return values
int|null —getResources()
Returns an array of resources loaded to build this collection.
public
getResources() : array<string|int, ResourceInterface>
Return values
array<string|int, ResourceInterface> —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