FileAccess Orion

Route
in package
implements Serializable

A Route describes a route and its parameters.

Tags
author

Fabien Potencier fabien@symfony.com

author

Tobias Schultze http://tobion.de

Interfaces, Classes, Traits and Enums

Serializable

Table of Contents

$compiled  : CompiledRoute|null
$condition  : mixed
$defaults  : mixed
$host  : mixed
$methods  : mixed
$options  : mixed
$path  : mixed
$requirements  : mixed
$schemes  : mixed
__construct()  : mixed
Constructor.
__serialize()  : array<string|int, mixed>
__unserialize()  : void
addDefaults()  : $this
Adds defaults.
addOptions()  : $this
Adds options.
addRequirements()  : $this
Adds requirements.
compile()  : CompiledRoute
Compiles the route.
getCondition()  : string
Returns the condition.
getDefault()  : mixed
Gets a default value.
getDefaults()  : array<string|int, mixed>
Returns the defaults.
getHost()  : string
Returns the pattern for the host.
getMethods()  : array<string|int, string>
Returns the uppercased HTTP methods this route is restricted to.
getOption()  : mixed
Get an option value.
getOptions()  : array<string|int, mixed>
Returns the options.
getPath()  : string
Returns the pattern for the path.
getRequirement()  : string|null
Returns the requirement for the given key.
getRequirements()  : array<string|int, mixed>
Returns the requirements.
getSchemes()  : array<string|int, string>
Returns the lowercased schemes this route is restricted to.
hasDefault()  : bool
Checks if a default value is set for the given variable.
hasOption()  : bool
Checks if an option has been set.
hasRequirement()  : bool
Checks if a requirement is set for the given key.
hasScheme()  : bool
Checks if a scheme requirement has been set.
setCondition()  : $this
Sets the condition.
setDefault()  : $this
Sets a default value.
setDefaults()  : $this
Sets the defaults.
setHost()  : $this
Sets the pattern for the host.
setMethods()  : $this
Sets the HTTP methods (e.g. 'POST') this route is restricted to.
setOption()  : $this
Sets an option value.
setOptions()  : $this
Sets the options.
setPath()  : $this
Sets the pattern for the path.
setRequirement()  : $this
Sets a requirement for the given key.
setRequirements()  : $this
Sets the requirements.
setSchemes()  : $this
Sets the schemes (e.g. 'https') this route is restricted to.
isLocalized()  : bool
sanitizeRequirement()  : mixed

Properties

$condition

private mixed $condition = ''

$defaults

private mixed $defaults = []

$host

private mixed $host = ''

$methods

private mixed $methods = []

$options

private mixed $options = []

$path

private mixed $path = '/'

$requirements

private mixed $requirements = []

$schemes

private mixed $schemes = []

Methods

__construct()

Constructor.

public __construct(string $path[, array<string|int, mixed> $defaults = [] ][, array<string|int, mixed> $requirements = [] ][, array<string|int, mixed> $options = [] ][, string|null $host = '' ][, string|array<string|int, string> $schemes = [] ][, string|array<string|int, string> $methods = [] ][, string|null $condition = '' ]) : mixed

Available options:

  • compiler_class: A class name able to compile this route instance (RouteCompiler by default)
  • utf8: Whether UTF-8 matching is enforced ot not
Parameters
$path : string

The path pattern to match

$defaults : array<string|int, mixed> = []

An array of default parameter values

$requirements : array<string|int, mixed> = []

An array of requirements for parameters (regexes)

$options : array<string|int, mixed> = []

An array of options

$host : string|null = ''

The host pattern to match

$schemes : string|array<string|int, string> = []

A required URI scheme or an array of restricted schemes

$methods : string|array<string|int, string> = []

A required HTTP method or an array of restricted methods

$condition : string|null = ''

A condition that should evaluate to true for the route to match

Return values
mixed

__serialize()

public __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__unserialize()

public __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>
Return values
void

addDefaults()

Adds defaults.

public addDefaults(array<string|int, mixed> $defaults) : $this

This method implements a fluent interface.

Parameters
$defaults : array<string|int, mixed>

The defaults

Return values
$this

addOptions()

Adds options.

public addOptions(array<string|int, mixed> $options) : $this

This method implements a fluent interface.

Parameters
$options : array<string|int, mixed>
Return values
$this

addRequirements()

Adds requirements.

public addRequirements(array<string|int, mixed> $requirements) : $this

This method implements a fluent interface.

Parameters
$requirements : array<string|int, mixed>

The requirements

Return values
$this

compile()

Compiles the route.

public compile() : CompiledRoute
Tags
throws
LogicException

If the Route cannot be compiled because the path or host pattern is invalid

see
RouteCompiler

which is responsible for the compilation process

Return values
CompiledRoute

A CompiledRoute instance

getCondition()

Returns the condition.

public getCondition() : string
Return values
string

The condition

getDefault()

Gets a default value.

public getDefault(string $name) : mixed
Parameters
$name : string
Return values
mixed

The default value or null when not given

getDefaults()

Returns the defaults.

public getDefaults() : array<string|int, mixed>
Return values
array<string|int, mixed>

The defaults

getHost()

Returns the pattern for the host.

public getHost() : string
Return values
string

The host pattern

getMethods()

Returns the uppercased HTTP methods this route is restricted to.

public getMethods() : array<string|int, string>

So an empty array means that any method is allowed.

Return values
array<string|int, string>

The methods

getOption()

Get an option value.

public getOption(string $name) : mixed
Parameters
$name : string
Return values
mixed

The option value or null when not given

getOptions()

Returns the options.

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

The options

getPath()

Returns the pattern for the path.

public getPath() : string
Return values
string

The path pattern

getRequirement()

Returns the requirement for the given key.

public getRequirement(string $key) : string|null
Parameters
$key : string
Return values
string|null

The regex or null when not given

getRequirements()

Returns the requirements.

public getRequirements() : array<string|int, mixed>
Return values
array<string|int, mixed>

The requirements

getSchemes()

Returns the lowercased schemes this route is restricted to.

public getSchemes() : array<string|int, string>

So an empty array means that any scheme is allowed.

Return values
array<string|int, string>

The schemes

hasDefault()

Checks if a default value is set for the given variable.

public hasDefault(string $name) : bool
Parameters
$name : string
Return values
bool

true if the default value is set, false otherwise

hasOption()

Checks if an option has been set.

public hasOption(string $name) : bool
Parameters
$name : string
Return values
bool

true if the option is set, false otherwise

hasRequirement()

Checks if a requirement is set for the given key.

public hasRequirement(string $key) : bool
Parameters
$key : string
Return values
bool

true if a requirement is specified, false otherwise

hasScheme()

Checks if a scheme requirement has been set.

public hasScheme(string $scheme) : bool
Parameters
$scheme : string
Return values
bool

true if the scheme requirement exists, otherwise false

setCondition()

Sets the condition.

public setCondition(string|null $condition) : $this

This method implements a fluent interface.

Parameters
$condition : string|null
Return values
$this

setDefault()

Sets a default value.

public setDefault(string $name, mixed $default) : $this
Parameters
$name : string
$default : mixed

The default value

Return values
$this

setDefaults()

Sets the defaults.

public setDefaults(array<string|int, mixed> $defaults) : $this

This method implements a fluent interface.

Parameters
$defaults : array<string|int, mixed>

The defaults

Return values
$this

setHost()

Sets the pattern for the host.

public setHost(string|null $pattern) : $this

This method implements a fluent interface.

Parameters
$pattern : string|null
Return values
$this

setMethods()

Sets the HTTP methods (e.g. 'POST') this route is restricted to.

public setMethods(string|array<string|int, string> $methods) : $this

So an empty array means that any method is allowed.

This method implements a fluent interface.

Parameters
$methods : string|array<string|int, string>

The method or an array of methods

Return values
$this

setOption()

Sets an option value.

public setOption(string $name, mixed $value) : $this

This method implements a fluent interface.

Parameters
$name : string
$value : mixed

The option value

Return values
$this

setOptions()

Sets the options.

public setOptions(array<string|int, mixed> $options) : $this

This method implements a fluent interface.

Parameters
$options : array<string|int, mixed>
Return values
$this

setPath()

Sets the pattern for the path.

public setPath(string $pattern) : $this

This method implements a fluent interface.

Parameters
$pattern : string
Return values
$this

setRequirement()

Sets a requirement for the given key.

public setRequirement(string $key, string $regex) : $this
Parameters
$key : string
$regex : string
Return values
$this

setRequirements()

Sets the requirements.

public setRequirements(array<string|int, mixed> $requirements) : $this

This method implements a fluent interface.

Parameters
$requirements : array<string|int, mixed>

The requirements

Return values
$this

setSchemes()

Sets the schemes (e.g. 'https') this route is restricted to.

public setSchemes(string|array<string|int, string> $schemes) : $this

So an empty array means that any scheme is allowed.

This method implements a fluent interface.

Parameters
$schemes : string|array<string|int, string>

The scheme or an array of schemes

Return values
$this

isLocalized()

private isLocalized() : bool
Return values
bool

sanitizeRequirement()

private sanitizeRequirement(string $key, string $regex) : mixed
Parameters
$key : string
$regex : string
Return values
mixed

Search results