CompositeUrlRule
API reference › yii › web › CompositeUrlRule
2 subclasses
CompositeUrlRule is the base class for URL rule classes that consist of multiple simpler rules.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$createUrlStatus read-only | int| | Status of the URL creation after the last createUrl() call. null if rule does not provide info about create status. | CompositeUrlRule |
$createStatus protected | int| | Status of the URL creation after the last createUrl() call. Default: null. Available since 2.0.12. | CompositeUrlRule |
$rules protected | UrlRuleInterface[]|UrlRuleInterface[][]| | The URL rules contained in this composite rule. Default: []. | CompositeUrlRule |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
createUrl() | Creates a URL according to the given route and parameters. | CompositeUrlRule |
getCreateUrlStatus() | Returns status of the URL creation after the last createUrl() call. | CompositeUrlRule |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | CompositeUrlRule |
parseRequest() | Parses the given request and returns the corresponding route and parameters. | CompositeUrlRule |
createRules() protected abstract | Creates the URL rules that should be contained within this composite rule. | CompositeUrlRule |
iterateRules() protected | Iterates through specified rules and calls createUrl() for each of them. | CompositeUrlRule |
Property details
Section titled “Property details”$rules
Section titled “$rules ”protected yii\web\UrlRuleInterface[]|yii\web\UrlRuleInterface[][]|array[]|string[] $rules = []The URL rules contained in this composite rule.
This property is set in init() by the return value of createRules().
Method details
Section titled “Method details”createUrl()
Section titled “createUrl() ”public function createUrl(mixed $manager, mixed $route, mixed $params): string|boolCreates a URL according to the given route and parameters.
Parameters
| Parameter | Type | Description |
|---|---|---|
$manager | mixed | The URL manager |
$route | mixed | The route. It should not have slashes at the beginning or the end. |
$params | mixed | The parameters |
Returns
string|bool: The created URL, or false if this rule cannot be used for creating this URL.
getCreateUrlStatus()
Section titled “getCreateUrlStatus() ”public function getCreateUrlStatus(): int|nullReturns status of the URL creation after the last createUrl() call.
For multiple rules statuses will be combined by bitwise or operator
(e.g. UrlRule::CREATE_STATUS_PARSING_ONLY | UrlRule::CREATE_STATUS_PARAMS_MISMATCH).
Returns
int|null: Status of the URL creation after the last createUrl() call. null if rule does not provide info about create status.
Since
2.0.12
See also
init()
Section titled “init() ”public function init(): mixedInitializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
Returns
mixed
parseRequest()
Section titled “parseRequest() ”public function parseRequest(mixed $manager, mixed $request): array|boolParses the given request and returns the corresponding route and parameters.
Parameters
| Parameter | Type | Description |
|---|---|---|
$manager | mixed | The URL manager |
$request | mixed | The request component |
Returns
array|bool: 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.
createRules()
Section titled “createRules() ”abstract protected function createRules(): yii\web\UrlRuleInterface[]|yii\web\UrlRuleInterface[][]Creates the URL rules that should be contained within this composite rule.
Returns
UrlRuleInterface[]|UrlRuleInterface[][]: The URL rules
iterateRules()
Section titled “iterateRules() ”protected function iterateRules(yii\web\UrlRuleInterface[] $rules, yii\web\UrlManager $manager, string $route, array $params): bool|stringIterates through specified rules and calls createUrl() for each of them.
Parameters
| Parameter | Type | Description |
|---|---|---|
$rules | UrlRuleInterface[] | Rules to iterate. |
$manager | UrlManager | The URL manager |
$route | string | The route. It should not have slashes at the beginning or the end. |
$params | array | The parameters |
Returns
bool|string: The created URL, or false if none of specified rules cannot be used for creating this URL.
Since
2.0.12
See also