Permalink
Browse files

merged branch Brammm/master (PR #7601)

This PR was merged into the master branch.

Discussion
----------

[Security] [Acl] [BasicPermissionMap] Made $map protected and moved it to __construct

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

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. 

Commits
-------

1369d54 Made $map protected and moved it to construct.
  • Loading branch information...
2 parents b265c9e + 1369d54 commit 69c57947b64c613fa6b1f9bb4a8dff2ce5fc3609 @fabpot fabpot committed Apr 9, 2013
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 69c5794

Please sign in to comment.