MaskBuilder
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
Parameters
| int | $mask | optional; defaults to 0 |
Exceptions
| InvalidArgumentException |
MaskBuilder add(mixed $mask)
Adds a mask to the permission
Parameters
| mixed | $mask |
Return Value
| MaskBuilder |
Exceptions
| InvalidArgumentException |
int get()
Returns the mask of this permission
Return Value
| int |
string getPattern()
Returns a human-readable representation of the permission
Return Value
| string |
MaskBuilder remove(mixed $mask)
Removes a mask from the permission
Parameters
| mixed | $mask |
Return Value
| MaskBuilder |
Exceptions
| InvalidArgumentException |
MaskBuilder reset()
Resets the PermissionBuilder
Return Value
| MaskBuilder |
static string getCode(int $mask)
Returns the code for the passed mask
Parameters
| int | $mask |
Return Value
| string |
Exceptions
| InvalidArgumentException | |
| RuntimeException |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Security/Acl/Permission/MaskBuilder.html