PHP Класс Cake\Routing\Route\Route

Not normally created as a standalone. Use Router::connect() to create Routes for your application.
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$defaults array Default parameters for a Route
$keys array /:controller/:action/:id has 3 key elements
$options array An array of additional parameters for the Route.
$template string The routes template string.

Защищенные свойства (Protected)

Свойство Тип Описание
$_compiledRoute string The compiled route regular expression
$_extensions array List of connected extensions for this route.
$_greedy string Is this route a greedy route? Greedy routes have a /* in their template
$_name string The name for a route. Fetch with Route::getName();

Открытые методы

Метод Описание
__construct ( string $template, array | string $defaults = [], array $options = [] ) Constructor for a Route
__set_state ( array $fields ) : Route Set state magic method to support var_export
compile ( ) : array Compiles the route's regular expression.
compiled ( ) : boolean Check if a Route has been compiled into a regular expression.
extensions ( null | string | array $extensions = null ) : array | null Get/Set the supported extensions for this route.
getExtensions ( ) : array Get the supported extensions for this route.
getName ( ) : string Get the standardized plugin.controller:action name for a route.
match ( array $url, array $context = [] ) : string | false Check if a URL array matches this route instance.
parse ( string $url, string $method = '' ) : array | false Checks to see if the given URL can be parsed by this route.
setExtensions ( array $extensions ) Set the supported extensions for this route.
staticPath ( ) : string Get the static path portion for this route.

Защищенные методы

Метод Описание
_matchMethod ( array $url ) : boolean Check whether or not the URL's HTTP method matches.
_parseArgs ( string $args, string $context ) : array Parse passed parameters into a list of passed args.
_parseExtension ( string $url ) : array Removes the extension from $url if it contains a registered extension.
_persistParams ( array $url, array $params ) : array Apply persistent parameters to a URL array. Persistent parameters are a special key used during route creation to force route parameters to persist when omitted from a URL array.
_writeRoute ( ) : void Builds a route regular expression.
_writeUrl ( array $params, array $pass = [], array $query = [] ) : string Converts a matching route array into a URL string.

Описание методов

__construct() публичный Метод

### Options - _ext - Defines the extensions used for this route. - pass - Copies the listed parameters into params['pass'].
public __construct ( string $template, array | string $defaults = [], array $options = [] )
$template string Template string with parameter placeholders
$defaults array | string Defaults for the route.
$options array Array of additional options for the Route

__set_state() публичный статический Метод

This method helps for applications that want to implement router caching.
public static __set_state ( array $fields ) : Route
$fields array Key/Value of object attributes
Результат Route A new instance of the route

_matchMethod() защищенный Метод

Check whether or not the URL's HTTP method matches.
protected _matchMethod ( array $url ) : boolean
$url array The array for the URL being generated.
Результат boolean

_parseArgs() защищенный Метод

Return true if a given named $param's $val matches a given $rule depending on $context. Currently implemented rule types are controller, action and match that can be combined with each other.
protected _parseArgs ( string $args, string $context ) : array
$args string A string with the passed params. eg. /1/foo
$context string The current route context, which should contain controller/action keys.
Результат array Array of passed args.

_parseExtension() защищенный Метод

If no registered extension is found, no extension is returned and the URL is returned unmodified.
protected _parseExtension ( string $url ) : array
$url string The url to parse.
Результат array containing url, extension

_persistParams() защищенный Метод

Apply persistent parameters to a URL array. Persistent parameters are a special key used during route creation to force route parameters to persist when omitted from a URL array.
protected _persistParams ( array $url, array $params ) : array
$url array The array to apply persistent parameters to.
$params array An array of persistent values to replace persistent ones.
Результат array An array with persistent parameters applied.

_writeRoute() защищенный Метод

Uses the template, defaults and options properties to compile a regular expression that can be used to parse request strings.
protected _writeRoute ( ) : void
Результат void

_writeUrl() защищенный Метод

Composes the string URL using the template used to create the route.
protected _writeUrl ( array $params, array $pass = [], array $query = [] ) : string
$params array The params to convert to a string url
$pass array The additional passed arguments
$query array An array of parameters
Результат string Composed route string.

compile() публичный Метод

Modifies defaults property so all necessary keys are set and populates $this->names with the named routing elements.
public compile ( ) : array
Результат array Returns a string regular expression of the compiled route.

compiled() публичный Метод

Check if a Route has been compiled into a regular expression.
public compiled ( ) : boolean
Результат boolean

extensions() публичный Метод

Get/Set the supported extensions for this route.
Устаревший: 3.3.9 Use getExtensions/setExtensions instead.
public extensions ( null | string | array $extensions = null ) : array | null
$extensions null | string | array The extensions to set. Use null to get.
Результат array | null The extensions or null.

getExtensions() публичный Метод

Get the supported extensions for this route.
public getExtensions ( ) : array
Результат array

getName() публичный Метод

Get the standardized plugin.controller:action name for a route.
public getName ( ) : string
Результат string

match() публичный Метод

If the URL matches the route parameters and settings, then return a generated string URL. If the URL doesn't match the route parameters, false will be returned. This method handles the reverse routing or conversion of URL arrays into string URLs.
public match ( array $url, array $context = [] ) : string | false
$url array An array of parameters to check matching with.
$context array An array of the current request context. Contains information such as the current host, scheme, port, base directory and other url params.
Результат string | false Either a string URL for the parameters if they match or false.

parse() публичный Метод

If the route can be parsed an array of parameters will be returned; if not false will be returned. String URLs are parsed if they match a routes regular expression.
public parse ( string $url, string $method = '' ) : array | false
$url string The URL to attempt to parse.
$method string The HTTP method of the request being parsed.
Результат array | false An array of request parameters, or false on failure.

setExtensions() публичный Метод

Set the supported extensions for this route.
public setExtensions ( array $extensions )
$extensions array The extensions to set.

staticPath() публичный Метод

Get the static path portion for this route.
public staticPath ( ) : string
Результат string

Описание свойств

$_compiledRoute защищенное свойство

The compiled route regular expression
protected string $_compiledRoute
Результат string

$_extensions защищенное свойство

List of connected extensions for this route.
protected array $_extensions
Результат array

$_greedy защищенное свойство

Is this route a greedy route? Greedy routes have a /* in their template
protected string $_greedy
Результат string

$_name защищенное свойство

The name for a route. Fetch with Route::getName();
protected string $_name
Результат string

$defaults публичное свойство

Default parameters for a Route
public array $defaults
Результат array

$keys публичное свойство

/:controller/:action/:id has 3 key elements
public array $keys
Результат array

$options публичное свойство

An array of additional parameters for the Route.
public array $options
Результат array

$template публичное свойство

The routes template string.
public string $template
Результат string