Fixes #17341: Allow callable objects to be set to \yii\filters\AccessRule::$roleParams

This commit is contained in:
Alexander Kartavenko
2019-06-12 00:02:07 +03:00
committed by Alexander Makarov
parent 0165416c79
commit a226b76776
3 changed files with 34 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Yii Framework 2 Change Log
- Enh #17345: Improved performance of `yii\db\Connection::quoteColumnName()` (brandonkelly)
- Enh #17348: Improved performance of `yii\db\Connection::quoteTableName()` (brandonkelly)
- Enh #17353: Added `sameSite` support for `yii\web\Cookie` and `yii\web\Session::cookieParams` (rhertogh)
- Bug #17341: Allow callable objects to be set to `\yii\filters\AccessRule::$roleParams` (alexkart)
2.0.20 June 04, 2019

View File

@ -240,7 +240,7 @@ class AccessRule extends Component
}
} else {
if (!isset($roleParams)) {
$roleParams = $this->roleParams instanceof Closure ? call_user_func($this->roleParams, $this) : $this->roleParams;
$roleParams = !is_array($this->roleParams) && is_callable($this->roleParams) ? call_user_func($this->roleParams, $this) : $this->roleParams;
}
if ($user->can($item, $roleParams)) {
return true;