UrlRuleInterface
API reference › yii › web › UrlRuleInterface
Implemented by 2 types
UrlRuleInterface is the interface that should be implemented by URL rule classes.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
createUrl() abstract | Creates a URL according to the given route and parameters. | UrlRuleInterface |
parseRequest() abstract | Parses the given request and returns the corresponding route and parameters. | UrlRuleInterface |
Method details
Section titled “Method details”createUrl()
Section titled “createUrl() ”abstract public function createUrl(yii\web\UrlManager $manager, string $route, array $params): string|boolCreates a URL according to the given route and parameters.
Parameters
| Parameter | Type | Description |
|---|---|---|
$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
string|bool: The created URL, or false if this rule cannot be used for creating this URL.
parseRequest()
Section titled “parseRequest() ”abstract public function parseRequest(yii\web\UrlManager $manager, yii\web\Request $request): array|boolParses the given request and returns the corresponding route and parameters.
Parameters
| Parameter | Type | Description |
|---|---|---|
$manager | UrlManager | The URL manager |
$request | Request | 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.