yii\helpers\BaseUrl::normalizeRoute PHP Method

normalizeRoute() protected static method

A relative route is a route without a leading slash, such as "view", "post/view". - If the route is an empty string, the current [[\yii\web\Controller::route|route]] will be used; - If the route contains no slashes at all, it is considered to be an action ID of the current controller and will be prepended with [[\yii\web\Controller::uniqueId]]; - If the route has no leading slash, it is considered to be a route relative to the current module and will be prepended with the module's uniqueId. Starting from version 2.0.2, a route can also be specified as an alias. In this case, the alias will be converted into the actual route first before conducting the above transformation steps.
protected static normalizeRoute ( string $route ) : string
$route string the route. This can be either an absolute route or a relative route.
return string normalized route suitable for UrlManager
    protected static function normalizeRoute($route)
    {
        $route = Yii::getAlias((string) $route);
        if (strncmp($route, '/', 1) === 0) {
            // absolute route
            return ltrim($route, '/');
        }
        // relative route
        if (Yii::$app->controller === null) {
            throw new InvalidParamException("Unable to resolve the relative route: {$route}. No active controller is available.");
        }
        if (strpos($route, '/') === false) {
            // empty or an action ID
            return $route === '' ? Yii::$app->controller->getRoute() : Yii::$app->controller->getUniqueId() . '/' . $route;
        } else {
            // relative to module
            return ltrim(Yii::$app->controller->module->getUniqueId() . '/' . $route, '/');
        }
    }

Usage Example

 public static function normalizeRoute($route)
 {
     return parent::normalizeRoute($route);
 }