yii\filters\HostControl::denyAccess PHP Méthode

denyAccess() protected méthode

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.
protected denyAccess ( Action $action )
$action yii\base\Action the action to be executed.
    protected function denyAccess($action)
    {
        $response = Yii::$app->getResponse();
        $errorHandler = Yii::$app->getErrorHandler();
        $exception = new NotFoundHttpException(Yii::t('yii', 'Page not found.'));
        $response->setStatusCode($exception->statusCode, $exception->getMessage());
        $response->data = $errorHandler->renderFile($errorHandler->errorView, ['exception' => $exception]);
        $response->send();
        Yii::$app->end();
    }