CoolCMS API

UserRole extends UserRole
in package

Attributes
#[Entity]

Table of Contents

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>
$privileges  : Collection<int, UserPrivilege>
$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]

$privileges

protected Collection<int, UserPrivilege> $privileges
Attributes
#[CollectionOf]
\App\UI\Front\System\Models\Entities\UserPrivilege::class
#[InverseJoinColumn]
$name: "cms_system_user_role_privileges_user_role_privilege_id"
$referencedColumnName: "user_role_privilege_id"
#[JoinColumn]
$name: "cms_system_user_roles_user_role_id"
$referencedColumnName: "user_role_id"
#[JoinTable]
$name: "cms_system_user_role_privilege_relations"
#[ManyToMany]
$targetEntity: \App\UI\Front\System\Models\Entities\UserPrivilege::class
$inversedBy: "userRoles"

$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
$this

callInitMethods()

Calls `init{TraitName}()` for every used trait that defines such a method.

public callInitMethods() : void

getAllTraits()

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
bool

getCode()

public getCode() : string
Return values
string

getConditional()

public getConditional() : bool
Return values
bool

getImplicit()

public getImplicit() : string
Return values
string

getLft()

public getLft() : int
Return values
int

getName()

public getName() : string
Return values
string

getPrivileged()

public getPrivileged() : bool
Return values
bool

getPrivilegeRels()

public getPrivilegeRels() : Collection<int, TPrivilegeRel>
Return values
Collection<int, TPrivilegeRel>

getProtectLastHolder()

public getProtectLastHolder() : bool
Return values
bool

getRgt()

public getRgt() : int
Return values
int

getSetAfterRegistration()

public getSetAfterRegistration() : bool
Return values
bool

isAssignable()

public isAssignable() : bool
Return values
bool

isConditional()

public isConditional() : bool
Return values
bool

isPrivileged()

public isPrivileged() : bool
Return values
bool

isSetAfterRegistration()

public isSetAfterRegistration() : bool
Return values
bool

removePrivilegeRel()

public removePrivilegeRel(TPrivilegeRel $privilegeRel) : $this
Parameters
$privilegeRel : TPrivilegeRel
Return values
$this

setAssignable()

public setAssignable(bool $assignable) : $this
Parameters
$assignable : bool
Return values
$this

setCode()

public setCode(string $code) : $this
Parameters
$code : string
Return values
$this

setConditional()

public setConditional(bool $conditional) : $this
Parameters
$conditional : bool
Return values
$this

setId()

public setId(int|null $id) : $this
Parameters
$id : int|null
Return values
$this

setImplicit()

public setImplicit(string $implicit) : $this
Parameters
$implicit : string
Return values
$this

setLft()

public setLft(int $lft) : $this
Parameters
$lft : int
Return values
$this

setName()

public setName(string $name) : $this
Parameters
$name : string
Return values
$this

setPrivileged()

public setPrivileged(bool $privileged) : $this
Parameters
$privileged : bool
Return values
$this

setPrivilegeRels()

public setPrivilegeRels(Collection<int, TPrivilegeRel>|array<int, TPrivilegeRel> $privilegeRels) : $this
Parameters
$privilegeRels : Collection<int, TPrivilegeRel>|array<int, TPrivilegeRel>
Return values
$this

setProtectLastHolder()

public setProtectLastHolder(bool $protectLastHolder) : $this
Parameters
$protectLastHolder : bool
Return values
$this

setRgt()

public setRgt(int $rgt) : $this
Parameters
$rgt : int
Return values
$this

setSetAfterRegistration()

public setSetAfterRegistration(bool $setAfterRegistration) : $this
Parameters
$setAfterRegistration : bool
Return values
$this

getTraitsRecursive()

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>
Return values
array<string, string>
On this page

Search results