Documentation

Route
in package

Read onlyYes
FinalYes

Instantiation of a RouteDef, based on a given path.

The root route is the parent of all routes in the context of any request. It sets shared roles, but cannot be associated with a controller. As the path of any request starts with '/' (even '' as it is equivalent to '/'), and as a path segment is defined as each URL-decoded segment of the absolute path split by (before being decoded) forward slash, then the first path segment of any request is '', which matches the root route. The home route is the root route's child (assuming it is a parent route) with the key '', assuming it is defined.

Unlike RouteDef-s, a Route only knows about its direct parent, and not about its child routes.

Table of Contents

Properties

$def  : RouteDef
$params  : array<string|int, mixed>
$parent  : Route|null
$seg  : string

Methods

__construct()  : mixed
getFqcn()  : null|IRoutedController>
The FQCN of the controller associated with this route.
getParamOrNull()  : string|null
getPath()  : string
Compute the absolute path from the root route up to this route.
getRoles()  : array<int, string>

Properties

$params

public array<string|int, mixed> $params = []

Methods

__construct()

public __construct(RouteDef $def, string $seg, Route|null $parent[, array<int, string> $params = [] ]) : mixed
Parameters
$def : RouteDef

The associated route definition.

$seg : string
$parent : Route|null
$params : array<int, string> = []

the associated path segments of the path that instantiated the current route. For a parameterised route, only the segments corresponding to the arguments are passed.

Tags
todo

PathSegList?

getFqcn()

The FQCN of the controller associated with this route.

public getFqcn() : null|IRoutedController>
Return values
null|IRoutedController>

getParamOrNull()

public getParamOrNull(int $index) : string|null
Parameters
$index : int
Return values
string|null

the parameter from the given array at the given index, or null if the index is beyond the array's range.

getPath()

Compute the absolute path from the root route up to this route.

public getPath() : string

This will always have a leading slash.

Tags
todo

Should the root route return "/"? On one hand, it makes everything more consistent (a path always begins with "/"), on the other hand it makes it harder to generate a canonical URL for the home. (example.org instead of example.org/).

Return values
string

getRoles()

public getRoles() : array<int, string>
Return values
array<int, string>
On this page

Search results