From acb7b2ebbb0880311527b63c773abe33daa30513 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Sun, 31 May 2015 12:46:38 +0300 Subject: [PATCH] Fixes #8556: Extracted `yii\web\User::getAuthManager()` method --- framework/CHANGELOG.md | 1 + framework/web/User.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 425f57616d..c68a15c196 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -29,6 +29,7 @@ Yii Framework 2 Change Log - Enh #8566: Added support for 'only' and 'except' options for `yii\web\AssetManager::publish()` (klimov-paul) - Enh #8574: Added `yii\console\controllers\MessageController` support .pot file creation (pgaultier) - Chg #6354: `ErrorHandler::logException()` will now log the whole exception object instead of only its string representation (cebe) +- Chg #8556: Extracted `yii\web\User::getAuthManager()` method (samdark) 2.0.4 May 10, 2015 diff --git a/framework/web/User.php b/framework/web/User.php index 818efadaf6..f483d219f7 100644 --- a/framework/web/User.php +++ b/framework/web/User.php @@ -655,7 +655,7 @@ class User extends Component */ public function can($permissionName, $params = [], $allowCaching = true) { - $auth = Yii::$app->getAuthManager(); + $auth = $this->getAuthManager(); if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) { return $this->_access[$permissionName]; } @@ -666,4 +666,14 @@ class User extends Component return $access; } + + /** + * Returns auth manager associated with the user component. + * @return \yii\rbac\ManagerInterface + * @since 2.0.5 + */ + protected function getAuthManager() + { + return Yii::$app->getAuthManager(); + } }