This repository was archived by the owner on Apr 7, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathAclManager.php
More file actions
87 lines (67 loc) · 2.64 KB
/
Copy pathAclManager.php
File metadata and controls
87 lines (67 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace Problematic\AclManagerBundle\Domain;
use Symfony\Component\Security\Acl\Dbal\MutableAclProvider;
use Symfony\Component\Security\Acl\Domain\Acl;
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
use Symfony\Component\Security\Core\SecurityContext;
use Problematic\AclManagerBundle\Model\AclManagerInterface;
use Problematic\AclManagerBundle\Domain\AbstractAclManager;
use Problematic\AclManagerBundle\Model\PermissionContextInterface;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Symfony\Component\Security\Acl\Permission\MaskBuilder;
use Problematic\AclManagerBundle\Model\AclAccessCommand;
use Problematic\AclManagerBundle\Model\AclCommandContext;
use Symfony\Component\Security\Acl\Model\MutableAclInterface;
class AclManager extends AbstractAclManager
{
public function permit($identity)
{
return new AclAccessCommand('permit', $commandContext, $this);
}
public function deny($identity)
{
return $this->createAccessCommand('deny', $identity);
}
public function loadAcl($oid)
{
return $this->doLoadAcl($oid);
}
public function addPermission(MutableAclInterface $acl, PermissionContextInterface $context)
{
$this->doApplyPermission($acl, $context);
return $this;
}
public function revokePermission(MutableAclInterface $acl, PermissionContextInterface $context)
{
$this->doRevokePermission($acl, $context);
return $this;
}
public function revokeAllPermissions(MutableAclInterface $acl, PermissionContextInterface $context)
{
$this->doRevokeAllPermissions($acl, $context->getSecurityIdentity(), 'object');
return $this;
}
public function preloadAcls($objects)
{
$oids = array();
foreach ($objects as $object) {
$oid = ObjectIdentity::fromDomainObject($object);
$oids[] = $oid;
}
$acls = $this->getAclProvider()->findAcls($oids); // todo: do we need to do anything with these?
return $this;
}
public function deleteAclFor($domainObject)
{
$oid = ObjectIdentity::fromDomainObject($domainObject);
$this->getAclProvider()->deleteAcl($oid);
return $this;
}
private function createAccessCommand($access_type, $identity)
{
$commandContext = new AclCommandContext();
$identity = $this->doCreateSecurityIdentity($identity);
$commandContext->setSecurityIdentity($identity);
return new AclAccessCommand($access_type, $commandContext, $this);
}
}