protected function denyAccess($action)
    {
        $exception = new NotFoundHttpException(Yii::t('yii', 'Page not found.'));

        // use regular error handling if $this->fallbackHostInfo was set
        if (!empty(Yii::getApp()->getRequest()->hostName)) {
            throw $exception;
        }

        $response = Yii::getApp()->getResponse();
        $errorHandler = Yii::getApp()->getErrorHandler();

        $response->setStatusCode($exception->statusCode, $exception->getMessage());
        $response->data = $errorHandler->renderFile($errorHandler->errorView, ['exception' => $exception]);
        $response->send();

        Yii::getApp()->end();
    }
protected function denyAccess($action)
    {
        $exception = new NotFoundHttpException(Yii::t('yii', 'Page not found.'));

        // use regular error handling if $this->fallbackHostInfo was set
        if (!empty(Yii::getApp()->getRequest()->hostName)) {
            throw $exception;
        }

        $response = Yii::getApp()->getResponse();
        $errorHandler = Yii::getApp()->getErrorHandler();

        $response->setStatusCode($exception->statusCode, $exception->getMessage());
        $response->data = $errorHandler->renderFile($errorHandler->errorView, ['exception' => $exception]);
        $response->send();

        Yii::getApp()->end();
    }
protected function denyAccess ( $ action ) { $ exception = new NotFoundHttpException ( Yii :: t ( 'yii' , 'Page not found.' ) ) ; // use regular error handling if $this->fallbackHostInfo was set if ( ! empty ( Yii :: getApp ( ) -> getRequest ( ) -> hostName ) ) { throw $ exception ; } $ response = Yii :: getApp ( ) -> getResponse ( ) ; $ errorHandler = Yii :: getApp ( ) -> getErrorHandler ( ) ; $ response -> setStatusCode ( $ exception -> statusCode , $ exception -> getMessage ( ) ) ; $ response -> data = $ errorHandler -> renderFile ( $ errorHandler -> errorView , [ 'exception' => $ exception ] ) ; $ response -> send ( ) ; Yii :: getApp ( ) -> end ( ) ; }
Denies the access.
The default implementation will display 404 page right away, terminating the program execution.
You may override this method, creating your own deny access handler. While doing so, make sure you
avoid usage of the current requested host name, creation of absolute URL links, caching page parts and so on.
@param \yii\base\Action $action the action to be executed.
@throws NotFoundHttpException
Denies the access . The default implementation will display 404 page right away terminating the program execution . You may override this method creating your own deny access handler . While doing so make sure you avoid usage of the current requested host name creation of absolute URL links caching page parts and so on .