From f24454a45862fc1f387855b9b5787eedb97b6ae3 Mon Sep 17 00:00:00 2001 From: Daniel Schmidt Date: Tue, 21 Jan 2014 17:11:28 -0800 Subject: [PATCH] Renames AccessDeniedHttpException to ForbiddenHttpException in framework, docs, and extension files --- docs/guide/authorization.md | 2 +- extensions/debug/Module.php | 4 ++-- extensions/gii/Module.php | 4 ++-- framework/classes.php | 2 +- framework/web/AccessControl.php | 4 ++-- framework/web/User.php | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/guide/authorization.md b/docs/guide/authorization.md index df40f2fae4d..0e65381786a 100644 --- a/docs/guide/authorization.md +++ b/docs/guide/authorization.md @@ -248,7 +248,7 @@ public function editArticle($id) throw new NotFoundHttpException; } if (!\Yii::$app->user->checkAccess('edit_article', ['article' => $article])) { - throw new AccessDeniedHttpException; + throw new ForbiddenHttpException; } // ... } diff --git a/extensions/debug/Module.php b/extensions/debug/Module.php index 06f2b76fbf9..c1138433ecf 100644 --- a/extensions/debug/Module.php +++ b/extensions/debug/Module.php @@ -10,7 +10,7 @@ use Yii; use yii\base\Application; use yii\web\View; -use yii\web\AccessDeniedHttpException; +use yii\web\ForbiddenHttpException; /** * The Yii Debug Module provides the debug toolbar and debugger @@ -80,7 +80,7 @@ public function beforeAction($action) } elseif ($action->id === 'toolbar') { return false; } else { - throw new AccessDeniedHttpException('You are not allowed to access this page.'); + throw new ForbiddenHttpException('You are not allowed to access this page.'); } } diff --git a/extensions/gii/Module.php b/extensions/gii/Module.php index a7bb3ed43f6..30302b5ef71 100644 --- a/extensions/gii/Module.php +++ b/extensions/gii/Module.php @@ -8,7 +8,7 @@ namespace yii\gii; use Yii; -use yii\web\AccessDeniedHttpException; +use yii\web\ForbiddenHttpException; /** * This is the main module class for the Gii module. @@ -110,7 +110,7 @@ public function beforeAction($action) if ($this->checkAccess()) { return parent::beforeAction($action); } else { - throw new AccessDeniedHttpException('You are not allowed to access this page.'); + throw new ForbiddenHttpException('You are not allowed to access this page.'); } } diff --git a/framework/classes.php b/framework/classes.php index ea50822b225..38c6987f1c6 100644 --- a/framework/classes.php +++ b/framework/classes.php @@ -196,7 +196,7 @@ 'yii\validators\ValidationAsset' => YII_PATH . '/validators/ValidationAsset.php', 'yii\validators\Validator' => YII_PATH . '/validators/Validator.php', 'yii\web\AccessControl' => YII_PATH . '/web/AccessControl.php', - 'yii\web\AccessDeniedHttpException' => YII_PATH . '/web/AccessDeniedHttpException.php', + 'yii\web\ForbiddenHttpException' => YII_PATH . '/web/ForbiddenHttpException.php', 'yii\web\AccessRule' => YII_PATH . '/web/AccessRule.php', 'yii\web\Application' => YII_PATH . '/web/Application.php', 'yii\web\AssetBundle' => YII_PATH . '/web/AssetBundle.php', diff --git a/framework/web/AccessControl.php b/framework/web/AccessControl.php index b2230a7d6da..4499f5ce81f 100644 --- a/framework/web/AccessControl.php +++ b/framework/web/AccessControl.php @@ -130,14 +130,14 @@ public function beforeAction($action) * The default implementation will redirect the user to the login page if he is a guest; * if the user is already logged, a 403 HTTP exception will be thrown. * @param User $user the current user - * @throws AccessDeniedHttpException if the user is already logged in. + * @throws ForbiddenHttpException if the user is already logged in. */ protected function denyAccess($user) { if ($user->getIsGuest()) { $user->loginRequired(); } else { - throw new AccessDeniedHttpException(Yii::t('yii', 'You are not allowed to perform this action.')); + throw new ForbiddenHttpException(Yii::t('yii', 'You are not allowed to perform this action.')); } } } diff --git a/framework/web/User.php b/framework/web/User.php index d6948b62c67..b6f3568c9fc 100644 --- a/framework/web/User.php +++ b/framework/web/User.php @@ -323,7 +323,7 @@ public function setReturnUrl($url) * Note that when [[loginUrl]] is set, calling this method will NOT terminate the application execution. * * @return Response the redirection response if [[loginUrl]] is set - * @throws AccessDeniedHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set + * @throws ForbiddenHttpException the "Access Denied" HTTP exception if [[loginUrl]] is not set */ public function loginRequired() { @@ -334,7 +334,7 @@ public function loginRequired() if ($this->loginUrl !== null) { return Yii::$app->getResponse()->redirect($this->loginUrl); } else { - throw new AccessDeniedHttpException(Yii::t('yii', 'Login Required')); + throw new ForbiddenHttpException(Yii::t('yii', 'Login Required')); } }