Class

Symfony\Component\Routing\Route

class Route

A Route describes a route and its parameters.

Methods

__construct(string $pattern, array $defaults = array(), array $requirements = array(), array $options = array())

Constructor.

__clone()

string getPattern()

Returns the pattern.

Route setPattern(string $pattern)

Sets the pattern.

array getOptions()

Returns the options.

Route setOptions(array $options)

Sets the options.

Route setOption(string $name, mixed $value)

Sets an option value.

mixed getOption(string $name)

Get an option value.

array getDefaults()

Returns the defaults.

Route setDefaults(array $defaults)

Sets the defaults.

mixed getDefault(string $name)

Gets a default value.

Boolean hasDefault(string $name)

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

Route setDefault(string $name, mixed $default)

Sets a default value.

array getRequirements()

Returns the requirements.

Route setRequirements(array $requirements)

Sets the requirements.

string getRequirement(string $key)

Returns the requirement for the given key.

Route setRequirement(string $key, string $regex)

Sets a requirement for the given key.

CompiledRoute compile()

Compiles the route.

Details

at line 45
public __construct(string $pattern, array $defaults = array(), array $requirements = array(), array $options = array())

Constructor.

Available options:

Parameters

string $pattern The pattern to match
array $defaults An array of default parameter values
array $requirements An array of requirements for parameters (regexes)
array $options An array of options

at line 53
public __clone()

at line 63
public string getPattern()

Returns the pattern.

Return Value

string The pattern

at line 77
public Route setPattern(string $pattern)

Sets the pattern.

This method implements a fluent interface.

Parameters

string $pattern The pattern

Return Value

Route The current Route instance

at line 94
public array getOptions()

Returns the options.

Return Value

array The options

at line 108
public Route setOptions(array $options)

Sets the options.

This method implements a fluent interface.

Parameters

array $options The options

Return Value

Route The current Route instance

at line 129
public Route setOption(string $name, mixed $value)

Sets an option value.

This method implements a fluent interface.

Parameters

string $name An option name
mixed $value The option value

Return Value

Route The current Route instance

at line 143
public mixed getOption(string $name)

Get an option value.

Parameters

string $name An option name

Return Value

mixed The option value

at line 153
public array getDefaults()

Returns the defaults.

Return Value

array The defaults

at line 167
public Route setDefaults(array $defaults)

Sets the defaults.

This method implements a fluent interface.

Parameters

array $defaults The defaults

Return Value

Route The current Route instance

at line 184
public mixed getDefault(string $name)

Gets a default value.

Parameters

string $name A variable name

Return Value

mixed The default value

at line 196
public Boolean hasDefault(string $name)

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

Parameters

string $name A variable name

Return Value

Boolean true if the default value is set, false otherwise

at line 211
public Route setDefault(string $name, mixed $default)

Sets a default value.

Parameters

string $name A variable name
mixed $default The default value

Return Value

Route The current Route instance

at line 223
public array getRequirements()

Returns the requirements.

Return Value

array The requirements

at line 237
public Route setRequirements(array $requirements)

Sets the requirements.

This method implements a fluent interface.

Parameters

array $requirements The requirements

Return Value

Route The current Route instance

at line 254
public string getRequirement(string $key)

Returns the requirement for the given key.

Parameters

string $key The key

Return Value

string The regex

at line 269
public Route setRequirement(string $key, string $regex)

Sets a requirement for the given key.

Parameters

string $key The key
string $regex The regex

Return Value

Route The current Route instance

at line 281
public CompiledRoute compile()

Compiles the route.

Return Value

CompiledRoute A CompiledRoute instance