PHP Class Webiny\Component\Router\Route\RouteCollection

Note that if you store two routes with the same name, the first route will be overwritten.
Inheritance: use trait Webiny\Component\StdLib\StdLibTrait
Show file Open project: Webiny/Framework Class Usage Examples

Public Methods

Method Description
__construct ( ) Base constructor.
add ( string $name, Route $route ) Adds a Route to the end of current collection.
addOption ( string $name, array $attributes ) Adds an option for all the routes within the collection.
all ( ) : array Returns an array of all routes within the collection.
count ( ) : integer Returns the number of routes within the current collection.
get ( string $name ) : Route Returns the route under the given name.
prepend ( string $name, Route $route ) Adds a Route to the beginning of current collection.
remove ( string $name ) Removes the route under the given name.
setHost ( string $host ) Sets the host filter to all routes within the collection.
setMethods ( array | string $methods ) Sets the method filter to all routes within the collection.
setSchemes ( array | string $schemes ) Sets the scheme filter to all routes within the collection.

Method Details

__construct() public method

Base constructor.
public __construct ( )

add() public method

Adds a Route to the end of current collection.
public add ( string $name, Route $route )
$name string Route name.
$route Route Instance of Route.

addOption() public method

Adds an option for all the routes within the collection.
public addOption ( string $name, array $attributes )
$name string Name of the route parameter.
$attributes array Parameter attributes.

all() public method

Returns an array of all routes within the collection.
public all ( ) : array
return array

count() public method

Returns the number of routes within the current collection.
public count ( ) : integer
return integer

get() public method

Returns the route under the given name.
public get ( string $name ) : Route
$name string Name of the route.
return Route

prepend() public method

Adds a Route to the beginning of current collection.
public prepend ( string $name, Route $route )
$name string Route name.
$route Route Instance of Route.

remove() public method

Removes the route under the given name.
public remove ( string $name )
$name string Route name.

setHost() public method

Sets the host filter to all routes within the collection.
public setHost ( string $host )
$host string Host name. Example: www.webiny.com

setMethods() public method

Sets the method filter to all routes within the collection.
public setMethods ( array | string $methods )
$methods array | string Url method. Example: POST | GET

setSchemes() public method

Sets the scheme filter to all routes within the collection.
public setSchemes ( array | string $schemes )
$schemes array | string Url scheme. Example: https