UserRole
extends BaseEntity
in package
implements
IdentifiableInterface
uses
IdentifiableTrait, PrivilegeRelCollectionTrait
Tags
Attributes
- #[MappedSuperclass]
Table of Contents
Interfaces
- IdentifiableInterface
- Entity with a simple integer primary key. Most entities have one (often via {@see \App\Core\Traits\Shared\Models\Entities\IdentifiableTrait}); texts and links with a composite key do not, which is why `getId()` is not on {@see \App\Core\Base\BaseEntity}. Code that needs the id of a generic entity asks for this interface (parameter type, template bound, `instanceof`).
Properties
- $assignable : bool
- Whether the role may be assigned to a user through `cms_system_user_role_relations`.
- $code : string
- Stable role identifier for the RBAC resolver; `name` is an editable admin label, `code` is not. Unique in the db, no default validation here.
- $conditional : bool
- Conditional grant: `allowed=1` from a role with `conditional=1` means `ALLOW_IF_OWNER`, not `ALLOW`. An unconditional grant from another role still wins (or-combination), which is the trap here.
- $id : int|null
- $implicit : string
- Implicit assignment of the role without a row in the relation table: `none` = normal role (must be in `cms_system_user_role_relations`), `anonymous` = applies to `userId === null` (guest), `authenticated` = applies to every `userId > 0` (owner).
- $lft : int
- $name : string
- $privileged : bool
- Full write scope without the ownership check (field tier). Currently only `admin`.
- $privilegeRels : Collection<int, TPrivilegeRel>
- $protectLastHolder : bool
- Protected role: the last active holder cannot be deleted or lose the role; enforced by the Api `UserManager` (`UserRolePolicy`). Currently `admin`.
- $rgt : int
- $setAfterRegistration : bool
- $users : Collection<int, TUser>
Methods
- __construct() : mixed
- addPrivilegeRel() : $this
- callInitMethods() : void
- Calls `init{TraitName}()` for every used trait that defines such a method.
- clearPrivilegeRels() : $this
- getAllTraits() : array<string, string>
- Returns all traits the class uses, including those used by parent classes and nested traits.
- getAssignable() : bool
- getCode() : string
- getConditional() : bool
- getId() : int|null
- getImplicit() : string
- getLft() : int
- getName() : string
- getPrivileged() : bool
- getPrivilegeRels() : Collection<int, TPrivilegeRel>
- getProtectLastHolder() : bool
- getRgt() : int
- getSetAfterRegistration() : bool
- isAssignable() : bool
- isConditional() : bool
- isPersisted() : bool
- isPrivileged() : bool
- isSetAfterRegistration() : bool
- privilegeRelCollectionInit() : void
- removePrivilegeRel() : $this
- setAssignable() : $this
- setCode() : $this
- setConditional() : $this
- setId() : $this
- setImplicit() : $this
- setLft() : $this
- setName() : $this
- setPrivileged() : $this
- setPrivilegeRels() : $this
- setProtectLastHolder() : $this
- setRgt() : $this
- setSetAfterRegistration() : $this
- getTraitsRecursive() : array<string, string>
- Walks the trait list recursively and collects nested traits too.
Properties
$assignable
Whether the role may be assigned to a user through `cms_system_user_role_relations`.
protected
bool
$assignable
= true
owner (and future conditional roles) have false: they are implicit, not assignable
(conditional=1 must have assignable=0).
Attributes
- #[Column]
- $type: "boolean"
$code
Stable role identifier for the RBAC resolver; `name` is an editable admin label, `code` is not. Unique in the db, no default validation here.
protected
string
$code
= ''
Attributes
- #[Column]
- $type: "string"
- $length: 50
$conditional
Conditional grant: `allowed=1` from a role with `conditional=1` means `ALLOW_IF_OWNER`, not `ALLOW`. An unconditional grant from another role still wins (or-combination), which is the trap here.
protected
bool
$conditional
= false
Attributes
- #[Column]
- $type: "boolean"
$id
protected
int|null
$id
= null
Attributes
- #[Column]
- $type: "integer"
- $name: "user_role_id"
- #[GeneratedValue]
- #[Id]
$implicit
Implicit assignment of the role without a row in the relation table: `none` = normal role (must be in `cms_system_user_role_relations`), `anonymous` = applies to `userId === null` (guest), `authenticated` = applies to every `userId > 0` (owner).
protected
string
$implicit
= 'none'
Attributes
- #[Column]
- $type: "string"
- $length: 20
$lft
protected
int
$lft
= 0
Attributes
- #[Column]
- $type: "integer"
$name
protected
string
$name
= ''
Attributes
- #[Column]
- $type: "string"
- $length: 150
$privileged
Full write scope without the ownership check (field tier). Currently only `admin`.
protected
bool
$privileged
= false
Attributes
- #[Column]
- $type: "boolean"
$privilegeRels
protected
Collection<int, TPrivilegeRel>
$privilegeRels
= new ArrayCollection()
Attributes
- #[Transient]
$protectLastHolder
Protected role: the last active holder cannot be deleted or lose the role; enforced by the Api `UserManager` (`UserRolePolicy`). Currently `admin`.
protected
bool
$protectLastHolder
= false
Attributes
- #[Column]
- $type: "boolean"
- $name: "protect_last_holder"
$rgt
protected
int
$rgt
= 0
Attributes
- #[Column]
- $type: "integer"
$setAfterRegistration
protected
bool
$setAfterRegistration
= false
Attributes
- #[Column]
- $type: "boolean"
$users
protected
Collection<int, TUser>
$users
= new ArrayCollection()
Attributes
- #[Transient]
Methods
__construct()
public
__construct([int|null $id = null ][, string $name = '' ][, int $lft = 0 ][, int $rgt = 0 ][, bool $setAfterRegistration = false ][, string $code = '' ][, bool $assignable = true ][, string $implicit = 'none' ][, bool $conditional = false ][, bool $privileged = false ][, bool $protectLastHolder = false ][, Collection $privilegeRels = new ArrayCollection() ][, Collection $users = new ArrayCollection() ]) : mixed
Parameters
- $id : int|null = null
- $name : string = ''
- $lft : int = 0
- $rgt : int = 0
- $setAfterRegistration : bool = false
- $code : string = ''
- $assignable : bool = true
- $implicit : string = 'none'
- $conditional : bool = false
- $privileged : bool = false
- $protectLastHolder : bool = false
- $privilegeRels : Collection = new ArrayCollection()
- $users : Collection = new ArrayCollection()
addPrivilegeRel()
public
addPrivilegeRel(TPrivilegeRel $privilegeRel) : $this
Parameters
- $privilegeRel : TPrivilegeRel
Return values
$thiscallInitMethods()
Calls `init{TraitName}()` for every used trait that defines such a method.
public
callInitMethods() : void
clearPrivilegeRels()
public
clearPrivilegeRels() : $this
Return values
$thisgetAllTraits()
Returns all traits the class uses, including those used by parent classes and nested traits.
public
getAllTraits() : array<string, string>
Return values
array<string, string>getAssignable()
public
getAssignable() : bool
Return values
boolgetCode()
public
getCode() : string
Return values
stringgetConditional()
public
getConditional() : bool
Return values
boolgetId()
public
getId() : int|null
Return values
int|nullgetImplicit()
public
getImplicit() : string
Return values
stringgetLft()
public
getLft() : int
Return values
intgetName()
public
getName() : string
Return values
stringgetPrivileged()
public
getPrivileged() : bool
Return values
boolgetPrivilegeRels()
public
getPrivilegeRels() : Collection<int, TPrivilegeRel>
Return values
Collection<int, TPrivilegeRel>getProtectLastHolder()
public
getProtectLastHolder() : bool
Return values
boolgetRgt()
public
getRgt() : int
Return values
intgetSetAfterRegistration()
public
getSetAfterRegistration() : bool
Return values
boolisAssignable()
public
isAssignable() : bool
Return values
boolisConditional()
public
isConditional() : bool
Return values
boolisPersisted()
public
isPersisted() : bool
Return values
boolisPrivileged()
public
isPrivileged() : bool
Return values
boolisSetAfterRegistration()
public
isSetAfterRegistration() : bool
Return values
boolprivilegeRelCollectionInit()
public
privilegeRelCollectionInit() : void
removePrivilegeRel()
public
removePrivilegeRel(TPrivilegeRel $privilegeRel) : $this
Parameters
- $privilegeRel : TPrivilegeRel
Return values
$thissetAssignable()
public
setAssignable(bool $assignable) : $this
Parameters
- $assignable : bool
Return values
$thissetCode()
public
setCode(string $code) : $this
Parameters
- $code : string
Return values
$thissetConditional()
public
setConditional(bool $conditional) : $this
Parameters
- $conditional : bool
Return values
$thissetId()
public
setId(int|null $id) : $this
Parameters
- $id : int|null
Return values
$thissetImplicit()
public
setImplicit(string $implicit) : $this
Parameters
- $implicit : string
Return values
$thissetLft()
public
setLft(int $lft) : $this
Parameters
- $lft : int
Return values
$thissetName()
public
setName(string $name) : $this
Parameters
- $name : string
Return values
$thissetPrivileged()
public
setPrivileged(bool $privileged) : $this
Parameters
- $privileged : bool
Return values
$thissetPrivilegeRels()
public
setPrivilegeRels(Collection<int, TPrivilegeRel>|array<int, TPrivilegeRel> $privilegeRels) : $this
Parameters
- $privilegeRels : Collection<int, TPrivilegeRel>|array<int, TPrivilegeRel>
Return values
$thissetProtectLastHolder()
public
setProtectLastHolder(bool $protectLastHolder) : $this
Parameters
- $protectLastHolder : bool
Return values
$thissetRgt()
public
setRgt(int $rgt) : $this
Parameters
- $rgt : int
Return values
$thissetSetAfterRegistration()
public
setSetAfterRegistration(bool $setAfterRegistration) : $this
Parameters
- $setAfterRegistration : bool
Return values
$thisgetTraitsRecursive()
Walks the trait list recursively and collects nested traits too.
private
static getTraitsRecursive(array<string, string> $traits) : array<string, string>
Parameters
- $traits : array<string, string>