Route
in package
Convenience class representing a RouteDefinition instantiation, i.e. a couple (RouteDef, path).
As it is static, it makes sure on creation that its properties are consistent.
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.
Tags
Table of Contents
Properties
- $def : RouteDef
- $nParams : int<0, max>
- $nParamsMax : int<0, max>
- $pageConf : IPageConf|null
- $params : array<string|int, mixed>
- $parent : Route|null
- $path : string
- $roles : array<int, string>
- $seg : string
Methods
- __construct() : mixed
- getParamOrNull() : string|null
- isEqual() : bool
- Return true if both routes share the same route definition tree.
Properties
$def
public
RouteDef
$def
$nParams
public
int<0, max>
$nParams
$nParamsMax
public
int<0, max>
$nParamsMax
Maximum number of params allowed by the definition.
$pageConf
public
IPageConf|null
$pageConf
$params
public
array<string|int, mixed>
$params
= []
$parent
public
Route|null
$parent
$path
public
string
$path
Absolute HTTP path. If the route is the root route, an empty path. Never a single slash as the root route cannot accept parameters and cannot have a child with an empty seg.
$roles
public
array<int, string>
$roles
$seg
public
string
$seg
Methods
__construct()
public
__construct(RouteDef $def, Route|null $parent, string $seg[, array<int, string> $params = [] ]) : mixed
Parameters
- $def : RouteDef
-
The associated route definition.
- $parent : Route|null
- $seg : string
- $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
getParamOrNull()
public
getParamOrNull(int<0, max> $index) : string|null
Parameters
- $index : int<0, max>
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.
isEqual()
Return true if both routes share the same route definition tree.
public
isEqual(Route|null $route) : bool
This means that their definition is the same RouteDefinition INSTANCE, that their parent, if defined, is equal by this method's standards, and that other properties are strictly equal in terms of the data they contain.
Parameters
- $route : Route|null