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