у меня есть сайт с ролями rbac, и когда я получаю сообщение об ошибке из-за отсутствия доступа к некоторым страницам, я получаю белую страницу с ошибкой.
используйте эти коды для макета, но они не работают:
мой сайтУправление:
public function actionError()
{
$exception = Yii::$app->errorHandler->exception;
if ($exception !== null) {
$this->layout = 'main';
return $this->render('error', ['exception' => $exception]);
}
}
у меня есть эта функция в sitecontroller, и я думаю, что проблема в этом:
public function actions() {
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'captcha' => [
'class' => 'yii\captcha\CaptchaAction',
'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
],
];
}
основной.php:
'errorHandler' => [
'errorAction' => 'site/error',
],
ошибка. страница просмотра php
<?php
use yii\helpers\Html;
$this->title = $name;
?>
<div class="site-error">
<h1><?= Html::encode($this->title) ?></h1>
<div class="alert alert-danger">
<?= nl2br(Html::encode($message)) ?>
</div>
<p>
The above error occurred while the Web server was processing your request.
</p>
<p>
Please contact us if you think this is a server error. Thank you.
</p>
i test my web with other error and i understand that other errors show in my view layout truely but just access error not in layout