Browse Source

Fix ACL editor

Kévin Dunglas 11 years ago
parent
commit
56d69291d9

+ 5 - 3
Controller/CRUDController.php

@@ -724,20 +724,22 @@ class CRUDController extends Controller
     /**
     /**
      * Gets ACL users
      * Gets ACL users
      * 
      * 
-     * @return array
+     * @return \Traversable
      */
      */
     protected function getAclUsers()
     protected function getAclUsers()
     {
     {
+        $aclUsers = array();
+
         $userManagerServiceName = $this->container->getParameter('sonata.admin.security.acl_user_manager');
         $userManagerServiceName = $this->container->getParameter('sonata.admin.security.acl_user_manager');
         if ($userManagerServiceName !== null && $this->has($userManagerServiceName)) {
         if ($userManagerServiceName !== null && $this->has($userManagerServiceName)) {
             $userManager = $this->get($userManagerServiceName);
             $userManager = $this->get($userManagerServiceName);
 
 
             if (method_exists($userManager, 'findUsers')) {
             if (method_exists($userManager, 'findUsers')) {
-                return $userManager->findUsers();
+                $aclUsers = $userManager->findUsers();
             }
             }
         }
         }
         
         
-        return array();
+        return is_array($aclUsers) ? new \ArrayIterator($aclUsers) : $aclUsers;
     }
     }
 
 
     /**
     /**

+ 2 - 2
Security/Handler/AclSecurityHandler.php

@@ -166,10 +166,10 @@ class AclSecurityHandler implements AclSecurityHandlerInterface
     /**
     /**
      * {@inheritDoc}
      * {@inheritDoc}
      */
      */
-    public function findObjectAcls(array $oids, array $sids = array())
+    public function findObjectAcls(\Traversable $oids, array $sids = array())
     {
     {
         try {
         try {
-            $acls = $this->aclProvider->findAcls($oids, $sids);
+            $acls = $this->aclProvider->findAcls(iterator_to_array($oids), $sids);
         } catch (\Exception $e) {
         } catch (\Exception $e) {
             if ($e instanceof NotAllAclsFoundException) {
             if ($e instanceof NotAllAclsFoundException) {
                 $acls = $e->getPartialResult();
                 $acls = $e->getPartialResult();

+ 2 - 2
Security/Handler/AclSecurityHandlerInterface.php

@@ -67,13 +67,13 @@ interface AclSecurityHandlerInterface extends SecurityHandlerInterface
      *
      *
      * @abstract
      * @abstract
      *
      *
-     * @param array $oids an array of ObjectIdentityInterface implementations
+     * @param \Traversable $oids a collection of ObjectIdentityInterface implementations
      * @param array $sids an array of SecurityIdentityInterface implementations
      * @param array $sids an array of SecurityIdentityInterface implementations
      *
      *
      * @throws \Exception
      * @throws \Exception
      * @return \SplObjectStorage mapping the passed object identities to ACLs
      * @return \SplObjectStorage mapping the passed object identities to ACLs
      */
      */
-    public function findObjectAcls(array $oids, array $sids = array());
+    public function findObjectAcls(\Traversable $oids, array $sids = array());
 
 
     /**
     /**
      * Add an object owner ACE to the object ACL
      * Add an object owner ACE to the object ACL

+ 2 - 2
Util/ObjectAclManipulator.php

@@ -23,14 +23,14 @@ abstract class ObjectAclManipulator implements ObjectAclManipulatorInterface
      *
      *
      * @param OutputInterface      $output
      * @param OutputInterface      $output
      * @param AdminInterface       $admin
      * @param AdminInterface       $admin
-     * @param array                $oids             an array of ObjectIdentityInterface implementations
+     * @param \Traversable         $oids              a collection of ObjectIdentityInterface implementations
      * @param UserSecurityIdentity $securityIdentity
      * @param UserSecurityIdentity $securityIdentity
      *
      *
      * @throws \Exception
      * @throws \Exception
      *
      *
      * @return array [countAdded, countUpdated]
      * @return array [countAdded, countUpdated]
      */
      */
-    public function configureAcls(OutputInterface $output, AdminInterface $admin, array $oids, UserSecurityIdentity $securityIdentity = null)
+    public function configureAcls(OutputInterface $output, AdminInterface $admin, \Traversable $oids, UserSecurityIdentity $securityIdentity = null)
     {
     {
         $countAdded      = 0;
         $countAdded      = 0;
         $countUpdated    = 0;
         $countUpdated    = 0;