UrlRule ​
- Type
- Class
- Namespace
- craft\web
- Inherits
- craft\web\UrlRule » yii\web\UrlRule » yii\base\BaseObject
- Implements
- yii\base\Configurable, yii\web\UrlRuleInterface
- Since
- 3.0.0
Public Properties ​
| Property | Description |
|---|---|
| createUrlStatus | integer, null – Status of the URL creation after the last createUrl() call. |
| defaults | array – The default GET parameters (name => value) that this rule provides. |
| encodeParams | boolean – A value indicating if parameters should be url encoded. |
| host | string, null – The pattern used to parse and create the host info part of a URL (e.g. https://example.com). |
| mode | integer, null – A value indicating if this rule should be used for both request parsing and URL creation, parsing only, or creation only. |
| name | string, null – The name of this rule. |
| normalizer | yii\web\UrlNormalizer, array, false, null – The configuration for yii\web\UrlNormalizer used by this rule. |
| params | array – Parameters that should be passed to the controller. |
| pattern | string – The pattern used to parse and create the path info part of a URL. |
| route | string – The route to the controller action |
| suffix | string, null – The URL suffix used for this rule. |
| verb | string, array, null – The HTTP verb (e.g. GET, POST, DELETE) that this rule should match. |
params ​
- Type
- array
- Default value
[]
Parameters that should be passed to the controller.
Protected Properties ​
| Property | Description |
|---|---|
| createStatus | integer, null – Status of the URL creation after the last createUrl() call. |
| placeholders | array – List of placeholders for matching parameters names. |
Public Methods ​
| Method | Description |
|---|---|
| __call() | Calls the named method which is not a class method. |
| __construct() | Constructor. |
| __get() | Returns the value of an object property. |
| __isset() | Checks if a property is set, i.e. defined and not null. |
| __set() | Sets value of an object property. |
| __toString() | |
| __unset() | Sets an object property to null. |
| canGetProperty() | Returns a value indicating whether a property can be read. |
| canSetProperty() | Returns a value indicating whether a property can be set. |
| className() | Returns the fully qualified name of this class. |
| createUrl() | Creates a URL according to the given route and parameters. |
| getCreateUrlStatus() | Returns status of the URL creation after the last createUrl() call. |
| hasMethod() | Returns a value indicating whether a method is defined. |
| hasProperty() | Returns a value indicating whether a property is defined. |
| init() | Initializes this rule. |
| parseRequest() | Parses the given request and returns the corresponding route and parameters. |
| regexTokens() | Returns an array of regex tokens supported by URL rules. |
__construct() ​
Constructor.
Arguments ​
$config(array)
parseRequest() ​
Parses the given request and returns the corresponding route and parameters.
Arguments ​
$manager(yii\web\UrlManager) – The URL manager$request(yii\web\Request) – The request component
Returns ​
array, boolean – The parsing result. The route and the parameters are returned as an array. If false, it means this rule cannot be used to parse this path info.
regexTokens() ​
- Since
- 5.6.0
Returns an array of regex tokens supported by URL rules.
Returns ​
Protected Methods ​
| Method | Description |
|---|---|
| getNormalizer() | |
| getParamRules() | Returns list of regex for matching parameter. |
| hasNormalizer() | |
| substitutePlaceholderNames() | Iterates over placeholders and checks whether each placeholder exists as a key in $matches array. |
Constants ​
| Constant | Description |
|---|---|
CREATE_STATUS_PARAMS_MISMATCH | Represents the unsuccessful URL generation by last createUrl() call, because of mismatched or missing parameters. |
CREATE_STATUS_PARSING_ONLY | Represents the unsuccessful URL generation by last createUrl() call, because rule does not support creating URLs. |
CREATE_STATUS_ROUTE_MISMATCH | Represents the unsuccessful URL generation by last createUrl() call, because of mismatched route. |
CREATE_STATUS_SUCCESS | Represents the successful URL generation by last createUrl() call. |
CREATION_ONLY | Set mode with this value to mark that this rule is for URL creation only. |
PARSING_ONLY | Set mode with this value to mark that this rule is for URL parsing only. |