Documentation

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
author

Fabien Potencier fabien@symfony.com

author

Tobias Schultze http://tobion.de

implements

\IteratorAggregate<string, Route>

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

Methods

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
throws
InvalidArgumentException

if the alias is for itself

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

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

getIterator()

Gets the current RouteCollection as an Iterator that includes all routes.

public getIterator() : ArrayIterator<string, Route>

It implements \IteratorAggregate.

Tags
see
all()
Return values
ArrayIterator<string, Route>

getPriority()

public getPriority(string $name) : int|null
Parameters
$name : string
Return values
int|null

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

Return values
mixed

Search results