Route
class Route implements Serializable
A Route describes a route and its parameters.
Methods
Constructor.
{@inheritdoc}
{@inheritdoc}
Returns the pattern for the path.
Sets the pattern for the path.
Returns the pattern for the host.
Sets 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.
Sets an option value.
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
__construct(string $path, array $defaults = array(), array $requirements = array(), array $options = array(), string|null $host = '', string|string[] $schemes = array(), string|string[] $methods = array(), string|null $condition = '')
Constructor.
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
$this
setPath(string $pattern)
Sets the pattern for the path.
This method implements a fluent interface.
$this
setHost(string $pattern)
Sets the pattern for the host.
This method implements a fluent interface.
string[]
getSchemes()
Returns the lowercased schemes this route is restricted to.
So an empty array means that any scheme is allowed.
$this
setSchemes(string|string[] $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.
string[]
getMethods()
Returns the uppercased HTTP methods this route is restricted to.
So an empty array means that any method is allowed.
$this
setMethods(string|string[] $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.
$this
setOption(string $name, mixed $value)
Sets an option value.
This method implements a fluent interface.
$this
setRequirements(array $requirements)
Sets the requirements.
This method implements a fluent interface.
$this
addRequirements(array $requirements)
Adds requirements.
This method implements a fluent interface.