CheckAccessInterface
API reference › yii › rbac › CheckAccessInterface
Implemented by 1 type
For more details and usage information on CheckAccessInterface, see the guide article on security authorization.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
checkAccess() abstract | Checks if the user has the specified permission. | CheckAccessInterface |
Method details
Section titled “Method details”checkAccess()
Section titled “checkAccess() ”abstract public function checkAccess(string|int $userId, string $permissionName, array $params = []): boolChecks if the user has the specified permission.
Parameters
| Parameter | Type | Description |
|---|---|---|
$userId | string| | The user ID. This should be either an integer or a string representing the unique identifier of a user. See User::$id. |
$permissionName | string | The name of the permission to be checked against |
$params | array | Name-value pairs that will be passed to the rules associated with the roles and permissions assigned to the user. |
Returns
bool: Whether the user has the specified permission.
Throws
yii\base\InvalidArgumentException: if $permissionName does not refer to an existing permission