| 1 | <?php |
||
| 5 | class User extends \yii\web\User |
||
| 6 | { |
||
| 7 | 93 | public function init() |
|
| 15 | |||
| 16 | /** |
||
| 17 | * Checks if the user can perform the operation as specified by the given permission. |
||
| 18 | * |
||
| 19 | * Note that you must configure "authManager" application component in order to use this method. |
||
| 20 | * Otherwise an exception will be thrown. |
||
| 21 | * |
||
| 22 | * @param string $permissionName the name of the permission (e.g. "edit post") that needs access check. |
||
| 23 | * @param array $params name-value pairs that would be passed to the rules associated |
||
| 24 | * with the roles and permissions assigned to the user. A param with name 'user' is added to |
||
| 25 | * this array, which holds the value of [[id]]. |
||
| 26 | * @param boolean $allowCaching whether to allow caching the result of access check. |
||
| 27 | * When this parameter is true (default), if the access check of an operation was performed |
||
| 28 | * before, its result will be directly returned when calling this method to check the same |
||
| 29 | * operation. If this parameter is false, this method will always call |
||
| 30 | * [[\yii\rbac\ManagerInterface::checkAccess()]] to obtain the up-to-date access result. Note that this |
||
| 31 | * caching is effective only within the same request and only works when `$params = []`. |
||
| 32 | * @return boolean whether the user can perform the operation as specified by the given permission. |
||
| 33 | */ |
||
| 34 | 25 | public function can($permissionName, $params = [], $allowCaching = true) |
|
| 41 | } |
||
| 42 |