33 abstract public function init();
38 foreach ($this->providers as $provider) {
39 $provider->saveAcl($aclElement);
44 foreach ($this->providers as $provider) {
45 $provider->removeAcl($aclElement);
50 foreach ($this->providers as $provider) {
51 $provider->savePart($aclPart);
56 foreach ($this->providers as $provider) {
57 $provider->updatePart($id,$aclPart);
62 foreach ($this->providers as $provider) {
63 $provider->removePart($aclPart);
69 unset($this->roles[$roleName]);
76 if (isset($this->elementsCache[$name])) {
77 unset($this->elementsCache[$name]);
83 unset($this->permissions[$permissionName]);
85 $this->
removeAcl(
null,
null, $permissionName);
91 unset($this->resources[$resourceName]);
97 public function removeAcl(
string $roleName =
null,
string $resourceName =
null,
string $permissionName =
null) {
99 foreach ($this->acls as $index => $acl) {
100 if (($resourceName ==
null || $acl->getResource()->getName() === $resourceName) && ($roleName ==
null || $acl->getRole()->getName() === $roleName) && ($permissionName ==
null || $acl->getPermission()->getName() === $permissionName)) {
101 foreach ($this->providers as $provider) {
102 $provider->removeAcl($acl);
104 $toRemove[] = $index;
107 foreach ($toRemove as $remove) {
108 unset($this->acls[$remove]);
113 foreach ($this->providers as $provider) {
114 if (! $provider->isAutosave()) {
115 $provider->saveAll();
121 foreach ($this->providers as $provider) {
122 if (! $provider->isAutosave() && $provider->cacheUpdated()) {
135 $this->roles[$role->
getName()] = $role;
136 $this->savePart($role);
140 $this->resources[$resource->
getName()] = $resource;
141 $this->savePart($resource);
145 $this->permissions[$permission->
getName()] = $permission;
146 $this->savePart($permission);
150 $oldRole = $this->getRoleByName($roleName);
152 $this->updatePart($roleName, $role);
157 $oldResource = $this->getResourceByName($resourceName);
159 $this->updatePart($resourceName, $resource);
164 $oldPermission = $this->getPermissionByName($permissionName);
165 if ($oldPermission) {
166 $this->updatePart($permissionName, $permission);
171 $perm = $this->getPermissionByName($name);
172 $perm->setLevel($level);
173 $this->updatePart($name, $perm);
176 public function allow(
string $roleName,
string $resourceName,
string $permissionName, $id=
null) {
179 $aclElm->allow($this->getRoleByName($roleName), $this->getResourceByName($resourceName), $this->getPermissionByName($permissionName));
180 $this->acls[] = $aclElm;
181 $this->saveAclElement($aclElm);
184 public function addAndAllow(
string $roleName,
string $resourceName,
string $permissionName, $id=
null) {
185 if (! $this->elementExistByName($roleName, $this->roles)) {
186 $this->addRole(
new Role($roleName));
188 if ($resourceName !==
'*' && ! $this->elementExistByName($resourceName, $this->resources)) {
189 $this->addResource(
new Resource($resourceName));
191 if ($permissionName !==
'ALL' && ! $this->elementExistByName($permissionName, $this->permissions)) {
192 $this->addPermission(
new Permission($permissionName));
194 $this->allow($roleName, $resourceName ??
'*', $permissionName ??
'ALL', $id);
198 return $this->elementExistByName($roleName, $this->roles);
202 return $this->elementExistByName($resourceName, $this->resources);
206 return $this->elementExistByName($permissionName, $this->permissions);
Ubiquity\security\acl\models$AbastractAclElement This class is part of Ubiquity.
Ubiquity\security\acl\models$AclElement This class is part of Ubiquity.
Ubiquity\security\acl\models$Permission This class is part of Ubiquity.
Ubiquity\security\acl\models$Resource This class is part of Ubiquity.
Ubiquity\security\acl\models$Role This class is part of Ubiquity.
allow(string $roleName, string $resourceName, string $permissionName, $id=null)
addResource(Resource $resource)
removeAcl(string $roleName=null, string $resourceName=null, string $permissionName=null)
removePart(AbstractAclPart $aclPart)
getPermissionByName(string $name)
addPermission(Permission $permission)
saveAclElement(AclElement $aclElement)
elementExistByName(string $name, array $inArray)
updatePermission(String $permissionName, Permission $permission)
updateResource(String $resourceName, Resource $resource)
removeResource(string $resourceName)
roleExists(string $roleName)
resourceExists(string $resourceName)
updatePart(string $id, AbstractAclPart $aclPart)
removePermission(string $permissionName)
addAndAllow(string $roleName, string $resourceName, string $permissionName, $id=null)
removeAclElement(AclElement $aclElement)
getRoleByName(string $name)
permissionExists(string $permissionName)
setPermissionLevel(string $name, int $level)
getResourceByName(string $name)
removeRole(string $roleName)
savePart(AbstractAclPart $aclPart)
updateRole(String $roleName, Role $role)
Ubiquity\security\acl\persistence$AclProviderInterface This class is part of Ubiquity.