Role
class Role (View source)
A role. These roles can be structured in a tree.
Constants
ROLE_IDENTIFIER_PATTERN |
|
Properties
protected string | $identifier | The identifier of this role |
|
protected string | $name | The name of this role (without package key) |
|
protected string | $packageKey | The package key this role belongs to (extracted from the identifier) |
|
protected bool | $abstract | Whether or not the role is "abstract", meaning it can't be assigned to accounts directly but only serves as a "template role" for other roles to inherit from |
|
protected Role[] | $parentRoles | ||
protected PrivilegeInterface[] | $privileges |
Methods
No description
Returns the fully qualified identifier of this role
The key of the package that defines this role.
The name of this role, being the identifier without the package key.
No description
Whether or not this role is "abstract", meaning it can't be assigned to accounts directly but only serves as a "template role" for other roles to inherit from
Assign parent roles to this role.
Returns an array of all directly assigned parent roles.
Returns all (directly and indirectly reachable) parent roles for the given role.
Returns true if the given role is a directly assigned parent of this role.
Assign privileges to this role.
No description
No description
No description
Returns the string representation of this role (the identifier)
Details
__construct(string $identifier, array $parentRoles = [])
No description
string
getIdentifier()
Returns the fully qualified identifier of this role
string
getPackageKey()
The key of the package that defines this role.
string
getName()
The name of this role, being the identifier without the package key.
void
setAbstract(bool $abstract)
No description
bool
isAbstract()
Whether or not this role is "abstract", meaning it can't be assigned to accounts directly but only serves as a "template role" for other roles to inherit from
void
setParentRoles(array $parentRoles)
Assign parent roles to this role.
Role[]
getParentRoles()
Returns an array of all directly assigned parent roles.
Role[]
getAllParentRoles()
Returns all (directly and indirectly reachable) parent roles for the given role.
void
addParentRole(Role $parentRole)
Add a (direct) parent role to this role.
bool
hasParentRole(Role $role)
Returns true if the given role is a directly assigned parent of this role.
void
setPrivileges(array $privileges)
Assign privileges to this role.
PrivilegeInterface[]
getPrivileges()
No description
PrivilegeInterface[]
getPrivilegesByType(string $className)
No description
PrivilegeInterface
getPrivilegeForTarget(string $privilegeTargetIdentifier, array $privilegeParameters = [])
No description
void
addPrivilege(PrivilegeInterface $privilege)
Add a privilege to this role.
string
__toString()
Returns the string representation of this role (the identifier)