Permalink
Browse files

Made $map protected and moved it to construct.

By making $map protected and moving it to the construct, you can simply extend the BasicPermissionMap class if you want to simply add some extra permissions. In it's current form, you have to copy/paste the entire array AND the getMasks and contains functions. 
  • Loading branch information...
Brammm committed Apr 8, 2013
1 parent 83e078a commit 1369d54db824aee4fe90e7ebca12105a3e6e0888
Showing with 56 additions and 51 deletions.
  1. +56 −51 src/Symfony/Component/Security/Acl/Permission/BasicPermissionMap.php
@@ -28,58 +28,63 @@ class BasicPermissionMap implements PermissionMapInterface
const PERMISSION_MASTER = 'MASTER';
const PERMISSION_OWNER = 'OWNER';
- private $map = array(
- self::PERMISSION_VIEW => array(
- MaskBuilder::MASK_VIEW,
- MaskBuilder::MASK_EDIT,
- MaskBuilder::MASK_OPERATOR,
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
+ protected $map;
- self::PERMISSION_EDIT => array(
- MaskBuilder::MASK_EDIT,
- MaskBuilder::MASK_OPERATOR,
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
-
- self::PERMISSION_CREATE => array(
- MaskBuilder::MASK_CREATE,
- MaskBuilder::MASK_OPERATOR,
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
-
- self::PERMISSION_DELETE => array(
- MaskBuilder::MASK_DELETE,
- MaskBuilder::MASK_OPERATOR,
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
-
- self::PERMISSION_UNDELETE => array(
- MaskBuilder::MASK_UNDELETE,
- MaskBuilder::MASK_OPERATOR,
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
-
- self::PERMISSION_OPERATOR => array(
- MaskBuilder::MASK_OPERATOR,
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
-
- self::PERMISSION_MASTER => array(
- MaskBuilder::MASK_MASTER,
- MaskBuilder::MASK_OWNER,
- ),
-
- self::PERMISSION_OWNER => array(
- MaskBuilder::MASK_OWNER,
- ),
- );
+ public function __construct()
+ {
+ $this->map = array(
+ self::PERMISSION_VIEW => array(
+ MaskBuilder::MASK_VIEW,
+ MaskBuilder::MASK_EDIT,
+ MaskBuilder::MASK_OPERATOR,
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_EDIT => array(
+ MaskBuilder::MASK_EDIT,
+ MaskBuilder::MASK_OPERATOR,
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_CREATE => array(
+ MaskBuilder::MASK_CREATE,
+ MaskBuilder::MASK_OPERATOR,
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_DELETE => array(
+ MaskBuilder::MASK_DELETE,
+ MaskBuilder::MASK_OPERATOR,
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_UNDELETE => array(
+ MaskBuilder::MASK_UNDELETE,
+ MaskBuilder::MASK_OPERATOR,
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_OPERATOR => array(
+ MaskBuilder::MASK_OPERATOR,
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_MASTER => array(
+ MaskBuilder::MASK_MASTER,
+ MaskBuilder::MASK_OWNER,
+ ),
+
+ self::PERMISSION_OWNER => array(
+ MaskBuilder::MASK_OWNER,
+ ),
+ );
+ }
/**
* {@inheritDoc}

0 comments on commit 1369d54

Please sign in to comment.