1: <?php
2:
3: namespace ProgrammingAreHard\Arbiter\Domain;
4:
5: use ProgrammingAreHard\Arbiter\Model\PermissionMapInterface;
6: use Symfony\Component\Security\Acl\Permission\BasicPermissionMap;
7: use Symfony\Component\Security\Acl\Permission\MaskBuilder;
8:
9: class PermissionMap implements PermissionMapInterface
10: {
11: 12: 13: 14: 15:
16: protected $map = array(
17: BasicPermissionMap::PERMISSION_VIEW => MaskBuilder::MASK_VIEW,
18: BasicPermissionMap::PERMISSION_EDIT => MaskBuilder::MASK_EDIT,
19: BasicPermissionMap::PERMISSION_CREATE => MaskBuilder::MASK_CREATE,
20: BasicPermissionMap::PERMISSION_DELETE => MaskBuilder::MASK_DELETE,
21: BasicPermissionMap::PERMISSION_UNDELETE => MaskBuilder::MASK_UNDELETE,
22: BasicPermissionMap::PERMISSION_OPERATOR => MaskBuilder::MASK_OPERATOR,
23: BasicPermissionMap::PERMISSION_MASTER => MaskBuilder::MASK_MASTER,
24: BasicPermissionMap::PERMISSION_OWNER => MaskBuilder::MASK_OWNER
25: );
26:
27: 28: 29:
30: public function getMask($permission)
31: {
32: return $this->map[$permission];
33: }
34:
35: 36: 37:
38: public function getPermission($mask)
39: {
40: return array_search($mask, $this->map);
41: }
42:
43: 44: 45:
46: public function supportsPermission($permission)
47: {
48: return array_key_exists($permission, $this->map);
49: }
50:
51: 52: 53:
54: public function getIterator()
55: {
56: return new \ArrayIterator($this->map);
57: }
58: }