Property | Type | Description | |
---|---|---|---|
$_classes | array | Classes used by Router. | |
$_configurations | array | An array of loaded Route objects used to match Request objects against. | |
$_formatters | array | An array of named closures matching up to corresponding route parameter values. Used to format those values. | |
$_modifiers | array | Array of closures used to format route parameters when parsing URLs. | |
$_scope | string | If is set to true, the scope of the user's request will be used. saved | |
$_scopes | Contain the configuration of scopes. | ||
$_unicode | Flag for generating Unicode-capable routes. Turn this off if you don't need it, or if you're using a broken OS distribution (i.e. CentOS). |
Method | Description | |
---|---|---|
attach ( $name, $config = null, array $vars = [] ) | Attach a scope to a mount point. | |
attached ( $name = null, array $vars = [] ) : mixed | Returns an attached mount point configuration. | |
config ( array $config = [] ) : array | Modify Router configuration settings and dependencies. | |
connect ( string | object $template, array | string $params = [], array | callable $options = [] ) : array | Connects a new route and returns the current routes array. This method creates a new Route object and registers it with the Router. The order in which routes are connected matters, since the order of precedence is taken into account in parsing and matching operations. | |
formatters ( array $formatters = [] ) : array | Used to get or set an array of named formatter closures, which are used to format route parameters when generating URLs. For example, for controller/action parameters to be dashed instead of underscored or camelBacked, you could do the following: | |
get ( integer $route = null, string | boolean $scope = null ) : object | array | null | Returns one or multiple connected routes. | |
match ( array | string $url = [], |
Attempts to match an array of route parameters (i.e. 'controller', 'action', etc.) against a connected Route object. For example, given the following route: | |
modifiers ( array $modifiers = [] ) : array | Used to get or set an array of named formatter closures, which are used to format route parameters when parsing URLs. For example, the following would match a posts/index url to a PostsController::indexAction() method. | |
parse ( object $request ) : array | Accepts an instance of lithium\action\Request (or a subclass) and matches it against each route, in the order that the routes are connected. | |
process ( |
Wrapper method which takes a Request object, parses it through all attached Route objects, assigns the resulting parameters to the Request object, and returns it. | |
reset ( ) | Resets the Router to its default state, unloading all routes. | |
scope ( string $name = null, Closure $closure = null ) : mixed | Scope getter/setter. |
Method | Description | |
---|---|---|
_compileScope ( array $config ) : array | Compiles the scope into regular expression patterns for matching against request URLs | |
_compileStack ( $stack ) | ||
_formatError ( $url ) | ||
_initScopes ( ) | Initialize static::$_scopes with a lithium\core\Configuration instance. | |
_matchOptions ( string | array &$url, |
Initialize options for Router::match(). | |
_parseController ( array $params ) | ||
_parseScope ( string $name, string $request ) : mixed | Return the unscoped url to route. | |
_parseString ( string $path, boolean $context, array $options = [] ) : array | Helper function for taking a path string and parsing it into a controller and action array. | |
_persist ( array $url, |
Copies persistent parameters (parameters in the request which have been designated to persist) to the current URL, unless the parameter has been explicitly disabled from persisting by setting the value in the URL to null, or by assigning some other value. | |
_prefix ( string $path, object $context = null, array $options = [] ) : string | Returns the prefix (scheme + hostname) for a URL based on the passed $options and the $context. | |
_prepareParams ( array | string $url, |
Prepares URL parameters for matching. Detects and Passes through un-routed URL strings, leaving them untouched. |
protected static _compileScope ( array $config ) : array | ||
$config | array | Array of settings. |
return | array | Returns the complied settings. |
protected static _initScopes ( ) |
protected static _matchOptions ( string | array &$url, |
||
$url | string | array | Options to match to a URL. Optionally, this can be a string containing a manually generated URL. |
$context | ||
$options | array | Options for the generation of the matched URL. |
return | array | The initialized options. |
protected static _parseController ( array $params ) | ||
$params | array |
protected static _persist ( array $url, |
||
$url | array | The parameters that define the URL to be matched. |
$context | A request object, which contains a `$persist` property, which is an array of keys to be persisted in URLs between requests. | |
return | array | Returns the modified URL array. |
protected static _prefix ( string $path, object $context = null, array $options = [] ) : string | ||
$path | string | The URL to be prefixed. |
$context | object | The request context. |
$options | array | Options for generating the proper prefix. Currently accepted values are: `'absolute' => true|false`, `'host' => string` and `'scheme' => string`. |
return | string | The prefixed URL, depending on the passed options. |
protected static _prepareParams ( array | string $url, |
||
$url | array | string | An array of parameters, shorthand parameter string or URL string. |
$context | ||
$options | array | |
return | array | string | Depending on the type of $url either a string or an array. |
public static connect ( string | object $template, array | string $params = [], array | callable $options = [] ) : array | ||
$template | string | object | An empty string, a route string `/` or an instance of `lithium\net\http\Route`. |
$params | array | string | An array describing the default or required elements of the route or alternatively a path string i.e. `Posts::index`. |
$options | array | callable | Either an array of options (`'handler'`, `'formatters'`, `'modifiers'`, `'unicode'` as well as any options for `Route`) or a callable that will be used as a route handler. |
return | array | Array of routes |
public static formatters ( array $formatters = [] ) : array | ||
$formatters | array | An array of named formatter closures to append to (or overwrite) the existing list. |
return | array | Returns the formatters array. |
public static get ( integer $route = null, string | boolean $scope = null ) : object | array | null | ||
$route | integer | Index of the route. |
$scope | string | boolean | Name of the scope to get routes from. Uses default scope if `true`. |
return | object | array | null | If $route is an integer, returns the route object at given index or if that fails returns `null`. If $route is `null` returns an array of routes or scopes with their respective routes depending on the value of $scope. |
public static match ( array | string $url = [], |
||
$url | array | string | An array of parameters to match, or paremeters in their shorthand form (i.e. `'Posts::view'`). Also takes non-routed, manually generated URL strings. |
$context | This supplies the context for any persistent parameters, as well as the base URL for the application. | |
$options | array | Options for the generation of the matched URL. Currently accepted values are: - `'absolute'` _boolean_: Indicates whether or not the returned URL should be an absolute path (i.e. including scheme and host name). - `'host'` _string_: If `'absolute'` is `true`, sets the host name to be used, or overrides the one provided in `$context`. - `'scheme'` _string_: If `'absolute'` is `true`, sets the URL scheme to be used, or overrides the one provided in `$context`. - `'scope'` _string_: Optionnal scope name. |
return | string | Returns a generated URL, based on the URL template of the matched route, and prefixed with the base URL of the application. |
public static parse ( object $request ) : array | ||
$request | object | A request object containing URL and environment data. |
return | array | Returns an array of parameters specifying how the given request should be routed. The keys returned depend on the `Route` object that was matched, but typically include `'controller'` and `'action'` keys. |
public static process ( |
||
$request | ||
return | Returns a copy of the request with parameters applied. |
public static reset ( ) |
public static scope ( string $name = null, Closure $closure = null ) : mixed | ||
$name | string | Name of the scope to use. |
$closure | Closure | A closure to execute inside the scope. |
return | mixed | Returns the previous scope if if `$name` is not null and `$closure` is null, returns the default used scope if `$name` is null, otherwise returns `null`. |
protected static array $_classes | ||
return | array |
protected static array $_configurations | ||
return | array |
protected static array $_formatters | ||
return | array |
protected static array $_modifiers | ||
return | array |
protected static string $_scope | ||
return | string |