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 | ||
MaskBuilder | 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 | |
MaskBuilder | remove(mixed $mask) Removes a mask from the permission | |
MaskBuilder | reset() Resets the PermissionBuilder | |
static string | getCode(int $mask) Returns the code for the passed mask |
Details
__construct(int $mask)
Constructor
MaskBuilder 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
MaskBuilder remove(mixed $mask)
Removes a mask from the permission
MaskBuilder reset()
Resets the PermissionBuilder
static string getCode(int $mask)
Returns the code for the passed mask
Please login to continue.