1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Symfony\Component\Security\Acl\Permission;
13:
14: 15: 16: 17: 18: 19:
20: class BasicPermissionMap implements PermissionMapInterface
21: {
22: const PERMISSION_VIEW = 'VIEW';
23: const PERMISSION_EDIT = 'EDIT';
24: const PERMISSION_CREATE = 'CREATE';
25: const PERMISSION_DELETE = 'DELETE';
26: const PERMISSION_UNDELETE = 'UNDELETE';
27: const PERMISSION_OPERATOR = 'OPERATOR';
28: const PERMISSION_MASTER = 'MASTER';
29: const PERMISSION_OWNER = 'OWNER';
30:
31: protected $map;
32:
33: public function __construct()
34: {
35: $this->map = array(
36: self::PERMISSION_VIEW => array(
37: MaskBuilder::MASK_VIEW,
38: MaskBuilder::MASK_EDIT,
39: MaskBuilder::MASK_OPERATOR,
40: MaskBuilder::MASK_MASTER,
41: MaskBuilder::MASK_OWNER,
42: ),
43:
44: self::PERMISSION_EDIT => array(
45: MaskBuilder::MASK_EDIT,
46: MaskBuilder::MASK_OPERATOR,
47: MaskBuilder::MASK_MASTER,
48: MaskBuilder::MASK_OWNER,
49: ),
50:
51: self::PERMISSION_CREATE => array(
52: MaskBuilder::MASK_CREATE,
53: MaskBuilder::MASK_OPERATOR,
54: MaskBuilder::MASK_MASTER,
55: MaskBuilder::MASK_OWNER,
56: ),
57:
58: self::PERMISSION_DELETE => array(
59: MaskBuilder::MASK_DELETE,
60: MaskBuilder::MASK_OPERATOR,
61: MaskBuilder::MASK_MASTER,
62: MaskBuilder::MASK_OWNER,
63: ),
64:
65: self::PERMISSION_UNDELETE => array(
66: MaskBuilder::MASK_UNDELETE,
67: MaskBuilder::MASK_OPERATOR,
68: MaskBuilder::MASK_MASTER,
69: MaskBuilder::MASK_OWNER,
70: ),
71:
72: self::PERMISSION_OPERATOR => array(
73: MaskBuilder::MASK_OPERATOR,
74: MaskBuilder::MASK_MASTER,
75: MaskBuilder::MASK_OWNER,
76: ),
77:
78: self::PERMISSION_MASTER => array(
79: MaskBuilder::MASK_MASTER,
80: MaskBuilder::MASK_OWNER,
81: ),
82:
83: self::PERMISSION_OWNER => array(
84: MaskBuilder::MASK_OWNER,
85: ),
86: );
87: }
88:
89: 90: 91:
92: public function getMasks($permission, $object)
93: {
94: if (!isset($this->map[$permission])) {
95: return;
96: }
97:
98: return $this->map[$permission];
99: }
100:
101: 102: 103:
104: public function contains($permission)
105: {
106: return isset($this->map[$permission]);
107: }
108: }
109: