class MaskBuilder

This class allows you to build cumulative permissions easily, or convert masks to a human-readable format.

$builder = new MaskBuilder(); $builder ->add('view') ->add('create') ->add('edit') ; vardump($builder->get()); // int(7) vardump($builder->getPattern()); // string(32) ".............................ECV"

We have defined some commonly used base permissions which you can use: - VIEW: the SID is allowed to view the domain object / field - CREATE: the SID is allowed to create new instances of the domain object / fields - EDIT: the SID is allowed to edit existing instances of the domain object / field - DELETE: the SID is allowed to delete domain objects - UNDELETE: the SID is allowed to recover domain objects from trash - OPERATOR: the SID is allowed to perform any action on the domain object except for granting others permissions - MASTER: the SID is allowed to perform any action on the domain object, and is allowed to grant other SIDs any permission except for MASTER and OWNER permissions - OWNER: the SID is owning the domain object in question and can perform any action on the domain object as well as grant any permission

Constants

MASK_VIEW

MASK_CREATE

MASK_EDIT

MASK_DELETE

MASK_UNDELETE

MASK_OPERATOR

MASK_MASTER

MASK_OWNER

MASK_IDDQD

CODE_VIEW

CODE_CREATE

CODE_EDIT

CODE_DELETE

CODE_UNDELETE

CODE_OPERATOR

CODE_MASTER

CODE_OWNER

ALL_OFF

OFF

ON

Methods

__construct(int $mask)

Constructor

add(mixed $mask)

Adds a mask to the permission

int
get()

Returns the mask of this permission

string
getPattern()

Returns a human-readable representation of the permission

remove(mixed $mask)

Removes a mask from the permission

reset()

Resets the PermissionBuilder

static string
getCode(int $mask)

Returns the code for the passed mask

Details

at line line 79
__construct(int $mask)

Constructor

Parameters

int $mask optional; defaults to 0

Exceptions

InvalidArgumentException

at line line 97
MaskBuilder add(mixed $mask)

Adds a mask to the permission

Parameters

mixed $mask

Return Value

MaskBuilder

Exceptions

InvalidArgumentException

at line line 109
int get()

Returns the mask of this permission

Return Value

int

at line line 119
string getPattern()

Returns a human-readable representation of the permission

Return Value

string

at line line 147
MaskBuilder remove(mixed $mask)

Removes a mask from the permission

Parameters

mixed $mask

Return Value

MaskBuilder

Exceptions

InvalidArgumentException

at line line 159
MaskBuilder reset()

Resets the PermissionBuilder

Return Value

MaskBuilder

at line line 174
static string getCode(int $mask)

Returns the code for the passed mask

Parameters

int $mask

Return Value

string

Exceptions

InvalidArgumentException
RuntimeException