Route
class Route implements Serializable
A Route describes a route and its parameters.
Methods
Constructor.
{@inheritdoc}
{@inheritdoc}
Returns the pattern for the path.
Returns the pattern for the host.
Returns the lowercased schemes this route is restricted to.
Sets the schemes (e.g. 'https') this route is restricted to.
Checks if a scheme requirement has been set.
Returns the uppercased HTTP methods this route is restricted to.
Sets the HTTP methods (e.g. 'POST') this route is restricted to.
Returns the options.
Sets the options.
Adds options.
Get an option value.
Checks if an option has been set.
Returns the defaults.
Sets the defaults.
Adds defaults.
Gets a default value.
Checks if a default value is set for the given variable.
Sets a default value.
Returns the requirements.
Sets the requirements.
Adds requirements.
Returns the requirement for the given key.
Checks if a requirement is set for the given key.
Sets a requirement for the given key.
Returns the condition.
Sets the condition.
Compiles the route.
Details
at line line 83
__construct(string $path, array $defaults = array(), array $requirements = array(), array $options = array(), string $host = '', string|array $schemes = array(), string|array $methods = array(), string $condition = '')
Constructor.
Available options:
- compiler_class: A class name able to compile this route instance (RouteCompiler by default)
at line line 98
serialize()
{@inheritdoc}
at line line 116
unserialize($serialized)
{@inheritdoc}
at line line 140
string
getPath()
Returns the pattern for the path.
at line line 154
Route
setPath(string $pattern)
Sets the pattern for the path.
This method implements a fluent interface.
at line line 169
string
getHost()
Returns the pattern for the host.
at line line 183
Route
setHost(string $pattern)
Sets the pattern for the host.
This method implements a fluent interface.
at line line 197
array
getSchemes()
Returns the lowercased schemes this route is restricted to.
So an empty array means that any scheme is allowed.
at line line 212
Route
setSchemes(string|array $schemes)
Sets the schemes (e.g. 'https') this route is restricted to.
So an empty array means that any scheme is allowed.
This method implements a fluent interface.
at line line 227
bool
hasScheme(string $scheme)
Checks if a scheme requirement has been set.
at line line 238
array
getMethods()
Returns the uppercased HTTP methods this route is restricted to.
So an empty array means that any method is allowed.
at line line 253
Route
setMethods(string|array $methods)
Sets the HTTP methods (e.g. 'POST') this route is restricted to.
So an empty array means that any method is allowed.
This method implements a fluent interface.
at line line 266
array
getOptions()
Returns the options.
at line line 280
Route
setOptions(array $options)
Sets the options.
This method implements a fluent interface.
at line line 298
Route
addOptions(array $options)
Adds options.
This method implements a fluent interface.
at line line 318
Route
setOption(string $name, mixed $value)
Sets an option value.
This method implements a fluent interface.
at line line 333
mixed
getOption(string $name)
Get an option value.
at line line 345
bool
hasOption(string $name)
Checks if an option has been set.
at line line 355
array
getDefaults()
Returns the defaults.
at line line 369
Route
setDefaults(array $defaults)
Sets the defaults.
This method implements a fluent interface.
at line line 385
Route
addDefaults(array $defaults)
Adds defaults.
This method implements a fluent interface.
at line line 402
mixed
getDefault(string $name)
Gets a default value.
at line line 414
bool
hasDefault(string $name)
Checks if a default value is set for the given variable.
at line line 427
Route
setDefault(string $name, mixed $default)
Sets a default value.
at line line 440
array
getRequirements()
Returns the requirements.
at line line 454
Route
setRequirements(array $requirements)
Sets the requirements.
This method implements a fluent interface.
at line line 470
Route
addRequirements(array $requirements)
Adds requirements.
This method implements a fluent interface.
at line line 487
string|null
getRequirement(string $key)
Returns the requirement for the given key.
at line line 499
bool
hasRequirement(string $key)
Checks if a requirement is set for the given key.
at line line 512
Route
setRequirement(string $key, string $regex)
Sets a requirement for the given key.
at line line 525
string
getCondition()
Returns the condition.
at line line 539
Route
setCondition(string $condition)
Sets the condition.
This method implements a fluent interface.
at line line 557
CompiledRoute
compile()
Compiles the route.