コード例 #1
0
 public function findAllResources($namespace)
 {
     return $this->_mapper->findAllResources($namespace);
 }
コード例 #2
0
 public function removePermissions($ns, $removes)
 {
     $mapper = PermissionMapper::getInstance();
     $defualtRoles = $mapper->findAllRoles($ns);
     $defaultResources = $mapper->findAllResources($ns);
     foreach ($removes as $rule) {
         $roles = \App_Util_String::cleanCsvParam($rule, 'role', $defualtRoles);
         $resources = \App_Util_String::cleanCsvParam($rule, 'resource', null);
         if ($resources === null) {
             foreach ($roles as $role) {
                 try {
                     $mapper->removeRoleId($role, $ns);
                     \App::log()->notice("Removed role '{$role}' on namespace '{$ns}'");
                 } catch (NotFoundException $ex) {
                 }
             }
             continue;
         }
         $actions = \App_Util_String::cleanCsvParam($rule, 'action', array());
         foreach ($roles as $role) {
             foreach ($resources as $resource) {
                 if (empty($actions)) {
                     $mapper->unsetResource($ns, $role, $resource);
                     \App::log()->notice("Removed resource '{$resource}' for role '{$role}' on namespace '{$ns}'");
                 } else {
                     foreach ($actions as $action) {
                         $mapper->unsetPermission($ns, $role, $resource, $action);
                         \App::log()->notice("Removed permission '{$action}' of resource '{$resource}' for role '{$role}' on namespace '{$ns}'");
                     }
                 }
             }
         }
     }
 }
コード例 #3
0
 public function testRemoveNamespace()
 {
     $ns = $this->permissionMapper->getNamespace(self::ACL_NAMESPACE, false);
     $ns->dropCollection();
 }