class Route implements Serializable
A Route describes a route and its parameters.
__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. | ||
serialize() {@inheritdoc} | ||
unserialize($serialized) {@inheritdoc} | ||
string | getPath() Returns the pattern for the path. | |
$this | setPath(string $pattern) Sets the pattern for the path. | |
string | getHost() Returns the pattern for the host. | |
$this | setHost(string $pattern) Sets the pattern for the host. | |
string[] | getSchemes() Returns the lowercased schemes this route is restricted to. | |
$this | setSchemes(string|string[] $schemes) Sets the schemes (e.g. 'https') this route is restricted to. | |
bool | hasScheme(string $scheme) Checks if a scheme requirement has been set. | |
string[] | getMethods() Returns the uppercased HTTP methods this route is restricted to. | |
$this | setMethods(string|string[] $methods) Sets the HTTP methods (e.g. 'POST') this route is restricted to. | |
array | getOptions() Returns the options. | |
$this | setOptions(array $options) Sets the options. | |
$this | addOptions(array $options) Adds options. | |
$this | setOption(string $name, mixed $value) Sets an option value. | |
mixed | getOption(string $name) Get an option value. | |
bool | hasOption(string $name) Checks if an option has been set. | |
array | getDefaults() Returns the defaults. | |
$this | setDefaults(array $defaults) Sets the defaults. | |
$this | addDefaults(array $defaults) Adds defaults. | |
mixed | getDefault(string $name) Gets a default value. | |
bool | hasDefault(string $name) Checks if a default value is set for the given variable. | |
$this | setDefault(string $name, mixed $default) Sets a default value. | |
array | getRequirements() Returns the requirements. | |
$this | setRequirements(array $requirements) Sets the requirements. | |
$this | addRequirements(array $requirements) Adds requirements. | |
string|null | getRequirement(string $key) Returns the requirement for the given key. | |
bool | hasRequirement(string $key) Checks if a requirement is set for the given key. | |
$this | setRequirement(string $key, string $regex) Sets a requirement for the given key. | |
string | getCondition() Returns the condition. | |
$this | setCondition(string $condition) Sets the condition. | |
CompiledRoute | compile() Compiles the route. |
Constructor.
Available options:
string | $path | The path 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 |
string|null | $host | The host pattern to match |
string|string[] | $schemes | A required URI scheme or an array of restricted schemes |
string|string[] | $methods | A required HTTP method or an array of restricted methods |
string|null | $condition | A condition that should evaluate to true for the route to match |
{@inheritdoc}
{@inheritdoc}
$serialized |
Returns the pattern for the path.
string | The path pattern |
Sets the pattern for the path.
This method implements a fluent interface.
string | $pattern | The path pattern |
$this |
Returns the pattern for the host.
string | The host pattern |
Sets the pattern for the host.
This method implements a fluent interface.
string | $pattern | The host pattern |
$this |
Returns the lowercased schemes this route is restricted to.
So an empty array means that any scheme is allowed.
string[] | The 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|string[] | $schemes | The scheme or an array of schemes |
$this |
Checks if a scheme requirement has been set.
string | $scheme |
bool | true if the scheme requirement exists, otherwise false |
Returns the uppercased HTTP methods this route is restricted to.
So an empty array means that any method is allowed.
string[] | The 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.
string|string[] | $methods | The method or an array of methods |
$this |
Returns the options.
array | The options |
Sets the options.
This method implements a fluent interface.
array | $options | The options |
$this |
Adds options.
This method implements a fluent interface.
array | $options | The options |
$this |
Sets an option value.
This method implements a fluent interface.
string | $name | An option name |
mixed | $value | The option value |
$this |
Get an option value.
string | $name | An option name |
mixed | The option value or null when not given |
Checks if an option has been set.
string | $name | An option name |
bool | true if the option is set, false otherwise |
Returns the defaults.
array | The defaults |
Sets the defaults.
This method implements a fluent interface.
array | $defaults | The defaults |
$this |
Adds defaults.
This method implements a fluent interface.
array | $defaults | The defaults |
$this |
Gets a default value.
string | $name | A variable name |
mixed | The default value or null when not given |
Checks if a default value is set for the given variable.
string | $name | A variable name |
bool | true if the default value is set, false otherwise |
Sets a default value.
string | $name | A variable name |
mixed | $default | The default value |
$this |
Returns the requirements.
array | The requirements |
Sets the requirements.
This method implements a fluent interface.
array | $requirements | The requirements |
$this |
Adds requirements.
This method implements a fluent interface.
array | $requirements | The requirements |
$this |
Returns the requirement for the given key.
string | $key | The key |
string|null | The regex or null when not given |
Checks if a requirement is set for the given key.
string | $key | A variable name |
bool | true if a requirement is specified, false otherwise |
Sets a requirement for the given key.
string | $key | The key |
string | $regex | The regex |
$this |
Returns the condition.
string | The condition |
Sets the condition.
This method implements a fluent interface.
string | $condition | The condition |
$this |
Compiles the route.
CompiledRoute | A CompiledRoute instance |
LogicException | If the Route cannot be compiled because the path or host pattern is invalid |
RouteCompiler | which is responsible for the compilation process |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Routing/Route.html