PHP Класс Webiny\Component\Router\Route\Route

Наследование: use trait Webiny\Component\StdLib\StdLibTrait
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__construct ( string $path, string | array $callback, array $options = [], string $host = '', array $schemes = [], array $methods = [] ) Base constructor.
addOption ( string $name, array $attributes ) Adds a single route option.
compile ( ) : CompiledRoute Compiles the route object and returns an instance of CompiledRoute.
getCallback ( ) : string | array Get the attached callback name.
getHost ( ) : string Get current host name.
getMethods ( ) : array Get the current defined methods.
getOptions ( ) : array Returns route options.
getPath ( ) : string Get the route path.
getRealPath ( ) : string Get the real path.
getSchemes ( ) : array Get the current defined schemes.
getTags ( ) : array Get the route tags.
hasOption ( string $name ) : boolean Checks if route has options attached to the given parameter.
setCallback ( string | array $callback ) Set the route callback.
setHost ( string $host ) Sets the host name to the route.
setMethods ( array | string $methods ) Match only requests that are within this set of methods.
setOptions ( array $options ) Set route options.
setPath ( string $path ) Sets the route path.
setSchemes ( array | string $schemes ) Match only requests that are within this set of schemes.
setTags ( array $tags ) Sets the route tags.

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

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

Base constructor.
public __construct ( string $path, string | array $callback, array $options = [], string $host = '', array $schemes = [], array $methods = [] )
$path string Path with parameter names that identifies the route.
$callback string | array Attached callback for this route.
$options array List of options, mostly for parameters. Common option keys are 'pattern' and 'default'. Pattern defines the regular expression for the defined parameter. Default sets the default value for the parameter if it's not matched withing the route.
$host string Fully qualified host name that will be added as a filer for matching the url.
$schemes array An array of supported schemas that the url must match.
$methods array An array of supported methods that the url must match.

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

Adds a single route option.
public addOption ( string $name, array $attributes )
$name string Name of the parameter to which the option should be attached.
$attributes array An array of options.

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

Compiles the route object and returns an instance of CompiledRoute.
public compile ( ) : CompiledRoute
Результат CompiledRoute

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

Get the attached callback name.
public getCallback ( ) : string | array
Результат string | array

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

Example host name: webiny.com | www.webiny.com
public getHost ( ) : string
Результат string

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

Get the current defined methods.
public getMethods ( ) : array
Результат array

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

Returns route options.
public getOptions ( ) : array
Результат array

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

Get the route path.
public getPath ( ) : string
Результат string

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

Get the real path.
public getRealPath ( ) : string
Результат string

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

Get the current defined schemes.
public getSchemes ( ) : array
Результат array

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

Get the route tags.
public getTags ( ) : array
Результат array

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

Checks if route has options attached to the given parameter.
public hasOption ( string $name ) : boolean
$name string Name of the route parameter.
Результат boolean

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

Set the route callback.
public setCallback ( string | array $callback )
$callback string | array Callback that will be attached to this route. Note that this callback can be overwritten during the routing process.

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

When defining a host name, the route must first match the host in order that it could match the route path.
public setHost ( string $host )
$host string Host name.

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

Example methods: POST | GET
public setMethods ( array | string $methods )
$methods array | string Method(s) to match.

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

Set route options.
public setOptions ( array $options )
$options array An array of options. Each option must have a name and a list of attributes and their values. Common attributes are 'prefix' and 'default'.

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

Sets the route path.
public setPath ( string $path )
$path string Route path.

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

Example scheme: http | https
public setSchemes ( array | string $schemes )
$schemes array | string Scheme(s) to match.

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

Sets the route tags.
public setTags ( array $tags )
$tags array