Przeglądaj źródła

fix: use the object identity to delete ACL

Roel Sint 13 lat temu
rodzic
commit
03377a3fdd

+ 1 - 1
Admin/Admin.php

@@ -530,9 +530,9 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
     public function delete($object)
     {
         $this->preRemove($object);
+        $this->getSecurityHandler()->deleteObjectSecurity($this, $object);
         $this->getModelManager()->delete($object);
         $this->postRemove($object);
-        $this->getSecurityHandler()->deleteObjectSecurity($this, $object);
     }
 
     public function preUpdate($object)

+ 3 - 6
Security/Handler/AclSecurityHandler.php

@@ -146,10 +146,7 @@ class AclSecurityHandler implements AclSecurityHandlerInterface
     public function deleteObjectSecurity(AdminInterface $admin, $object)
     {
         $objectIdentity = ObjectIdentity::fromDomainObject($object);
-        if (!is_null($acl = $this->getObjectAcl($objectIdentity)))
-        {
-            $this->deleteAcl($acl);
-        }
+        $this->deleteAcl($objectIdentity);
     }
 
     /**
@@ -250,9 +247,9 @@ class AclSecurityHandler implements AclSecurityHandlerInterface
     /**
      * {@inheritDoc}
      */
-    public function deleteAcl(AclInterface $acl)
+    public function deleteAcl(ObjectIdentityInterface $objectIdentity)
     {
-        $this->aclProvider->deleteAcl($acl);
+        $this->aclProvider->deleteAcl($objectIdentity);
     }
 
     /**

+ 2 - 2
Security/Handler/AclSecurityHandlerInterface.php

@@ -110,10 +110,10 @@ interface AclSecurityHandlerInterface extends SecurityHandlerInterface
      * Delete the ACL
      *
      * @abstract
-     * @param AclInterface $acl
+     * @param ObjectIdentityInterface $objectIdentity
      * @return void
      */
-    function deleteAcl(AclInterface $acl);
+    function deleteAcl(ObjectIdentityInterface $objectIdentity);
 
     /**
      * Helper method to find the index of a class ACE for a role

+ 1 - 1
Util/AdminAclManipulator.php

@@ -56,7 +56,7 @@ class AdminAclManipulator implements AdminAclManipulatorInterface
             $this->securityHandler->updateAcl($acl);
         } else {
             $output->writeln(sprintf('   - %s , no roles and permissions found', ($newAcl ? 'skip' : 'removed')));
-            $this->securityHandler->deleteAcl($acl);
+            $this->securityHandler->deleteAcl($objectIdentity);
         }
     }