Skip to content
PHP Ecosystem
Explore

UrlRuleInterface

API reference › yii › web › UrlRuleInterface

interfaceyii\web\UrlRuleInterface
Since2.0
Sourceframework/web/UrlRuleInterface.php
Implemented by 2 types

UrlRuleInterface is the interface that should be implemented by URL rule classes.

MethodDescriptionDefined by
createUrl() abstractCreates a URL according to the given route and parameters.UrlRuleInterface
parseRequest() abstractParses the given request and returns the corresponding route and parameters.UrlRuleInterface
abstract public function createUrl(yii\web\UrlManager $manager, string $route, array $params): string|bool

Creates a URL according to the given route and parameters.

Parameters

ParameterTypeDescription
$managerUrlManagerThe URL manager
$routestringThe route. It should not have slashes at the beginning or the end.
$paramsarrayThe parameters

Returns

string|bool: The created URL, or false if this rule cannot be used for creating this URL.

abstract public function parseRequest(yii\web\UrlManager $manager, yii\web\Request $request): array|bool

Parses the given request and returns the corresponding route and parameters.

Parameters

ParameterTypeDescription
$managerUrlManagerThe URL manager
$requestRequestThe 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.