Fixes #8556: Extracted yii\web\User::getAuthManager() method

This commit is contained in:
Alexander Makarov
2015-05-31 12:46:38 +03:00
parent 4851d7f9e3
commit acb7b2ebbb
2 changed files with 12 additions and 1 deletions

View File

@ -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 #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) - 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 #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 2.0.4 May 10, 2015

View File

@ -655,7 +655,7 @@ class User extends Component
*/ */
public function can($permissionName, $params = [], $allowCaching = true) public function can($permissionName, $params = [], $allowCaching = true)
{ {
$auth = Yii::$app->getAuthManager(); $auth = $this->getAuthManager();
if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) { if ($allowCaching && empty($params) && isset($this->_access[$permissionName])) {
return $this->_access[$permissionName]; return $this->_access[$permissionName];
} }
@ -666,4 +666,14 @@ class User extends Component
return $access; 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();
}
} }