PHP Class Webiny\Component\Router\Route\Route

Inheritance: use trait Webiny\Component\StdLib\StdLibTrait
Afficher le fichier Open project: Webiny/Framework Class Usage Examples

Méthodes publiques

Méthode Description
__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.

Method Details

__construct() public méthode

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() public méthode

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() public méthode

Compiles the route object and returns an instance of CompiledRoute.
public compile ( ) : CompiledRoute
Résultat CompiledRoute

getCallback() public méthode

Get the attached callback name.
public getCallback ( ) : string | array
Résultat string | array

getHost() public méthode

Example host name: webiny.com | www.webiny.com
public getHost ( ) : string
Résultat string

getMethods() public méthode

Get the current defined methods.
public getMethods ( ) : array
Résultat array

getOptions() public méthode

Returns route options.
public getOptions ( ) : array
Résultat array

getPath() public méthode

Get the route path.
public getPath ( ) : string
Résultat string

getRealPath() public méthode

Get the real path.
public getRealPath ( ) : string
Résultat string

getSchemes() public méthode

Get the current defined schemes.
public getSchemes ( ) : array
Résultat array

getTags() public méthode

Get the route tags.
public getTags ( ) : array
Résultat array

hasOption() public méthode

Checks if route has options attached to the given parameter.
public hasOption ( string $name ) : boolean
$name string Name of the route parameter.
Résultat boolean

setCallback() public méthode

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() public méthode

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() public méthode

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

setOptions() public méthode

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() public méthode

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

setSchemes() public méthode

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

setTags() public méthode

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