Browse Source

isGranted now accepts an array of roles

Thomas Rabaix 14 năm trước cách đây
mục cha
commit
36ffb23fc8
1 tập tin đã thay đổi với 12 bổ sung2 xóa
  1. 12 2
      Admin/Admin.php

+ 12 - 2
Admin/Admin.php

@@ -1870,8 +1870,18 @@ abstract class Admin implements AdminInterface, DomainObjectInterface
      * @param string $name
      * @return boolean
      */
-    public function isGranted($name)
+    public function isGranted($names)
     {
-        return $this->securityContext->isGranted($name, $this);
+        if (!is_array($names)) {
+            $names = (array) $names;
+        }
+
+        foreach($names as $name) {
+            if (true === $this->securityContext->isGranted($name, $this)) {
+                return true;
+            }
+        }
+
+        return false;
     }
 }