protected function _ensureUrl()
    {
        /*if (!\Yii::$app->urlManager->enablePrettyUrl) {
            return true;
        }*/

        if (\Yii::$app->urlManager->rules) {
            foreach (\Yii::$app->urlManager->rules as $rule) {
                if ($rule instanceof BackendUrlRule) {
                    $request = \Yii::$app->request;
                    $pathInfo = $request->getPathInfo();
                    $params = $request->getQueryParams();

                    //Если например нужно на главной странице сделать бэкенд
                    if (!$pathInfo) {
                        return true;
                    }

                    $firstPrefix = StringHelper::substr($pathInfo, 0, StringHelper::strlen($rule->urlPrefix));

                    if ($firstPrefix == $rule->urlPrefix) {
                        return true;
                    }
                }
            }
        }

        throw new NotFoundHttpException("This is controller allow only with urlPrefix!");
    }
protected function _ensureUrl()
    {
        /*if (!\Yii::$app->urlManager->enablePrettyUrl) {
            return true;
        }*/

        if (\Yii::$app->urlManager->rules) {
            foreach (\Yii::$app->urlManager->rules as $rule) {
                if ($rule instanceof BackendUrlRule) {
                    $request = \Yii::$app->request;
                    $pathInfo = $request->getPathInfo();
                    $params = $request->getQueryParams();

                    //Если например нужно на главной странице сделать бэкенд
                    if (!$pathInfo) {
                        return true;
                    }

                    $firstPrefix = StringHelper::substr($pathInfo, 0, StringHelper::strlen($rule->urlPrefix));

                    if ($firstPrefix == $rule->urlPrefix) {
                        return true;
                    }
                }
            }
        }

        throw new NotFoundHttpException("This is controller allow only with urlPrefix!");
    }
protected function _ensureUrl ( ) { /*if (!\Yii::$app->urlManager->enablePrettyUrl) {
            return true;
        }*/ if ( \ Yii :: $ app -> urlManager -> rules ) { foreach ( \ Yii :: $ app -> urlManager -> rules as $ rule ) { if ( $ rule instanceof BackendUrlRule ) { $ request = \ Yii :: $ app -> request ; $ pathInfo = $ request -> getPathInfo ( ) ; $ params = $ request -> getQueryParams ( ) ; //Если например нужно на главной странице сделать бэкенд if ( ! $ pathInfo ) { return true ; } $ firstPrefix = StringHelper :: substr ( $ pathInfo , 0 , StringHelper :: strlen ( $ rule -> urlPrefix ) ) ; if ( $ firstPrefix == $ rule -> urlPrefix ) { return true ; } } } } throw new NotFoundHttpException ( "This is controller allow only with urlPrefix!" ) ; }
Ensure prefix url

@return bool
@throws NotFoundHttpException
Ensure prefix url