Symfony\Component\Security\Acl\Permission\MaskBuilder
This class allows you to build cumulative permissions easily, or convert masks to a human-readable format.
<code>
$builder = new MaskBuilder();
$builder
->add('view')
->add('create')
->add('edit')
;
var_dump($builder->get()); // int(7)
var_dump($builder->getPattern()); // string(32) ".............................ECV"
</code>
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
- Author: Johannes M. Schmitt <schmittjoh@gmail.com>
Synopsis
- // constants
- const MASK_VIEW = 1;
- const MASK_CREATE = 2;
- const MASK_EDIT = 4;
- const MASK_DELETE = 8;
- const MASK_UNDELETE = 16;
- const MASK_OPERATOR = 32;
- const MASK_MASTER = 64;
- const MASK_OWNER = 128;
- const MASK_IDDQD = 1073741823;
- const CODE_VIEW = 'V';
- const CODE_CREATE = 'C';
- const CODE_EDIT = 'E';
- const CODE_DELETE = 'D';
- const CODE_UNDELETE = 'U';
- const CODE_OPERATOR = 'O';
- const CODE_MASTER = 'M';
- const CODE_OWNER = 'N';
- const ALL_OFF = '................................';
- const OFF = '.';
- const ON = '*';
- // members
- private $mask;
- // methods
- public void __construct()
- public MaskBuilder add()
- public integer get()
- public string getPattern()
- public MaskBuilder remove()
- public MaskBuilder reset()
- public static string getCode()
Constants
Name | Value |
---|---|
MASK_VIEW | 1 |
MASK_CREATE | 2 |
MASK_EDIT | 4 |
MASK_DELETE | 8 |
MASK_UNDELETE | 16 |
MASK_OPERATOR | 32 |
MASK_MASTER | 64 |
MASK_OWNER | 128 |
MASK_IDDQD | 1073741823 |
CODE_VIEW | 'V' |
CODE_CREATE | 'C' |
CODE_EDIT | 'E' |
CODE_DELETE | 'D' |
CODE_UNDELETE | 'U' |
CODE_OPERATOR | 'O' |
CODE_MASTER | 'M' |
CODE_OWNER | 'N' |
ALL_OFF | '................................' |
OFF | '.' |
ON | '*' |
Members
private
- $mask
Methods
public
- __construct() — Constructor
- add() — Adds a mask to the permission
- get() — Returns the mask of this permission
- getCode() — Returns the code for the passed mask
- getPattern() — Returns a human-readable representation of the permission
- remove() — Removes a mask from the permission
- reset() — Resets the PermissionBuilder