Permission
Table of Contents
- buildPermissionVariants() : array<string|int, string>
- Build permission variants for a given permission name
- hasAccessAll() : bool
- Check if the permission object (user or role) has all of the given permissions, wildcards count ("*.*" or "edit.*" cover "edit.article") and a user's permissions include those inherited from its roles
- hasAccessAnyOf() : bool
- Check if the permission object (user or role) has one of the permissions, wildcards included ("*.*" or "edit.*" cover "edit.article"); a user's role-inherited permissions count too
- permissionsAdd() : void
- Add permissions to an permission object (user or role)
- permissionsRemove() : void
- Remove permissions from the permission object (user or role)
Methods
buildPermissionVariants()
Build permission variants for a given permission name
public
static buildPermissionVariants(string $permissionName) : array<string|int, string>
e.g. "edit.article" => [".", "edit.", "edit.article.", "edit.article"]
Parameters
- $permissionName : string
-
The permission name to build variants for
Return values
array<string|int, string> —An array of permission variants
hasAccessAll()
Check if the permission object (user or role) has all of the given permissions, wildcards count ("*.*" or "edit.*" cover "edit.article") and a user's permissions include those inherited from its roles
public
hasAccessAll(array<string|int, string> ...$permissionNames) : bool
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to check
Return values
bool —True if the object has all of the permissions, false otherwise
hasAccessAnyOf()
Check if the permission object (user or role) has one of the permissions, wildcards included ("*.*" or "edit.*" cover "edit.article"); a user's role-inherited permissions count too
public
hasAccessAnyOf(array<string|int, string> ...$permissionNames) : bool
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to check
Return values
bool —True if the object has at least one of the permissions, false otherwise
permissionsAdd()
Add permissions to an permission object (user or role)
public
permissionsAdd(array<string|int, string> ...$permissionNames) : void
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to add
Return values
void —permissionsRemove()
Remove permissions from the permission object (user or role)
public
permissionsRemove(array<string|int, string> ...$permissionNames) : void
Parameters
- $permissionNames : array<string|int, string>
-
The names of the permissions to remove