Bladeren bron

[Security/Acl] some misc fixes

Johannes Schmitt 14 jaren geleden
bovenliggende
commit
f697fe3b26

+ 7 - 15
src/Symfony/Component/Security/Acl/Domain/PermissionGrantingStrategy.php

@@ -30,16 +30,8 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
     const ALL   = 'all';
     const ANY   = 'any';
 
-    private static $noAceException;
     private $auditLogger;
 
-    public function __construct()
-    {
-        if (null === static::$noAceException) {
-            static::$noAceException = new NoAceFoundException('No ACE.');
-        }
-    }
-
     /**
      * Sets the audit logger
      *
@@ -61,7 +53,7 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
                 $aces = $acl->getObjectAces();
 
                 if (!$aces) {
-                    throw static::$noAceException;
+                    throw new NoAceFoundException();
                 }
 
                 return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
@@ -69,7 +61,7 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
                 $aces = $acl->getClassAces();
 
                 if (!$aces) {
-                    throw static::$noAceException;
+                    throw $noObjectAce;
                 }
 
                 return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
@@ -79,7 +71,7 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
                 return $parentAcl->isGranted($masks, $sids, $administrativeMode);
             }
 
-            throw new NoAceFoundException('No applicable ACE was found.');
+            throw $noClassAce;
         }
     }
 
@@ -92,14 +84,14 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
             try {
                 $aces = $acl->getObjectFieldAces($field);
                 if (!$aces) {
-                    throw static::$noAceException;
+                    throw new NoAceFoundException();
                 }
 
                 return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
             } catch (NoAceFoundException $noObjectAces) {
                 $aces = $acl->getClassFieldAces($field);
                 if (!$aces) {
-                    throw static::$noAceException;
+                    throw $noObjectAces;
                 }
 
                 return $this->hasSufficientPermissions($acl, $aces, $masks, $sids, $administrativeMode);
@@ -109,7 +101,7 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
                 return $parentAcl->isFieldGranted($field, $masks, $sids, $administrativeMode);
             }
 
-            throw new NoAceFoundException('No applicable ACE was found.');
+            throw $noClassAces;
         }
     }
 
@@ -177,7 +169,7 @@ class PermissionGrantingStrategy implements PermissionGrantingStrategyInterface
             return false;
         }
 
-        throw static::$noAceException;
+        throw new NoAceFoundException();
     }
 
     /**

+ 4 - 0
src/Symfony/Component/Security/Acl/Exception/NoAceFoundException.php

@@ -19,4 +19,8 @@ namespace Symfony\Component\Security\Acl\Exception;
  */
 class NoAceFoundException extends Exception
 {
+    public function __construct()
+    {
+        parent::__construct('No applicable ACE was found.');
+    }
 }