Permission
Table of Contents
- $permissionChanged : mixed
- 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
- hasAccessAnyOf() : bool
- Check if the permission object (user or role) has one of the permissions
- permissionsAdd() : void
- Add permissions to an permission object (user or role)
- permissionsRemove() : void
- Remove permissions from the permission object (user or role)
Properties
$permissionChanged
protected
static mixed
$permissionChanged
= false
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
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
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