PHP Class Cake\Routing\RouteCollection

Provides an interface for adding/removing routes and parsing/generating URLs with the routes it contains.
Datei anzeigen Open project: cakephp/cakephp Class Usage Examples

Protected Properties

Property Type Description
$_extensions array Route extensions
$_named Cake\Routing\Route\Route[] The hash map of named routes that are in this collection.
$_paths array Routes indexed by path prefix.
$_routeTable array The routes connected to this collection.
$_routes Cake\Routing\Route\Route[] The routes connected to this collection.

Public Methods

Method Description
add ( Route $route, array $options = [] ) : void Add a route to the collection.
extensions ( null | string | array $extensions = null, boolean $merge = true ) : array Get/set the extensions that the route collection could handle.
match ( array $url, array $context ) : string | false Reverse route or match a $url array with the defined routes.
named ( ) : Route[] Get the connected named routes.
parse ( string $url, string $method = '' ) : array Takes the URL string and iterates the routes until one is able to parse the route.
routes ( ) : Route[] Get all the connected routes as a flat list.

Protected Methods

Method Description
_getNames ( array $url ) : array Get the set of names from the $url. Accepts both older style array urls, and newer style urls containing '_name'

Method Details

_getNames() protected method

Get the set of names from the $url. Accepts both older style array urls, and newer style urls containing '_name'
protected _getNames ( array $url ) : array
$url array The url to match.
return array The set of names of the url

add() public method

Add a route to the collection.
public add ( Route $route, array $options = [] ) : void
$route Cake\Routing\Route\Route The route object to add.
$options array Additional options for the route. Primarily for the `_name` option, which enables named routes.
return void

extensions() public method

Get/set the extensions that the route collection could handle.
public extensions ( null | string | array $extensions = null, boolean $merge = true ) : array
$extensions null | string | array Either the list of extensions to set, or null to get.
$merge boolean Whether to merge with or override existing extensions. Defaults to `true`.
return array The valid extensions.

match() public method

Returns either the string URL generate by the route, or false on failure.
public match ( array $url, array $context ) : string | false
$url array The url to match.
$context array The request context to use. Contains _base, _port, _host, _scheme and params keys.
return string | false Either a string on match, or false on failure.

named() public method

Get the connected named routes.
public named ( ) : Route[]
return Cake\Routing\Route\Route[]

parse() public method

Takes the URL string and iterates the routes until one is able to parse the route.
public parse ( string $url, string $method = '' ) : array
$url string URL to parse.
$method string The HTTP method to use.
return array An array of request parameters parsed from the URL.

routes() public method

Get all the connected routes as a flat list.
public routes ( ) : Route[]
return Cake\Routing\Route\Route[]

Property Details

$_extensions protected_oe property

Route extensions
protected array $_extensions
return array

$_named protected_oe property

The hash map of named routes that are in this collection.
protected Route[],Cake\Routing\Route $_named
return Cake\Routing\Route\Route[]

$_paths protected_oe property

Routes indexed by path prefix.
protected array $_paths
return array

$_routeTable protected_oe property

The routes connected to this collection.
protected array $_routeTable
return array

$_routes protected_oe property

The routes connected to this collection.
protected Route[],Cake\Routing\Route $_routes
return Cake\Routing\Route\Route[]