在应用程序登录中,我有以下代码会引发...HttpException
日志记录错误:
// common/models/LoginForm.php which is called from the backend SiteController actionLogin method as $model = new LoginForm();
public function loginAdmin()
{
//die($this->getUser()->getRoleValue()."hhh");
if ($this->getUser()->getRoleValue() >= ValueHelpers::getRoleValue('Admin') && $this->getUser()->getStatusValue() == ValueHelpers::getStatusValue('Active')){
if ($this->validate()){
return \Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600*24*30:0);
}
else{
throw new \yii\web\NotFoundHttpException('Incorrect Password or Username.');
}
}
else{
throw new \yii\web\ForbiddenHttpException('Insufficient privileges to access this area.');
}
}
它工作正常,但我想自定义使用 和 呈现的NotFoundHttpException
页面ForbiddenHttpException
。我试图搜索Yii2 api以找到任何可能在对象构造中定义视图的参数,但我找不到。那么,有没有办法自定义异常的视图呢?