@param ResourceInterface $resource

@return array|\CirclicalUser\Provider\GroupPermissionInterface[]
517891
public function getResourcePermissions(ResourceInterface $resource) : array
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId')
            ->setParameter('resourceClass', $resource->getClass())
            ->setParameter('resourceId', $resource->getId())
            ->getQuery();

        return $query->getResult();
    }
1105704
public function getPermissions(User $user, array $resourceIds) {
        
        $results = array();
        foreach ($this->getInner() as $impl) {
            $results[] = $impl->getPermissions($user, $resourceIds);
        }
        
        $rights = array();
        foreach ($resourceIds as $id) {
            $intersect = null;
            foreach ($results as $modelResult) {
                $intersect = is_null($intersect)
                    ? $modelResult[$id]
                    : array_intersect($intersect, $modelResult[$id]);
            }
            $rights[$id] = array_values($intersect);
        }
        
        return $rights;
    }
83182
protected function processIsGranted(RequesterInterface $requester, ResourceInterface $resource, $action, &$buffer = [])
    {
        try {
            $permission = $this->findPermission($requester, $resource);

            $isGranted = $permission->isGranted($action);
        } catch (PermissionNotFoundException $e) {
            $this->permissionBuffer->add($this->initPermission($requester, $resource, 0));

            $isGranted = false;
        }

        if (false === $isGranted && $requester instanceof CascadingRequesterInterface) {
            $buffer[] = $requester->getAclRequesterIdentifier();

            foreach ($requester->getAclParentsRequester() as $requesterParent) {
                if (in_array($requesterParent->getAclRequesterIdentifier(), $buffer)) {
                    return $isGranted;
                }

                $buffer[] = $requesterParent->getAclRequesterIdentifier();
                if (true === $this->processIsGranted($requesterParent, $resource, $action, $buffer)) {
                    return true;
                }
            }
        }

        return $isGranted;
    }
1108292
private function createDomainManagerDefinition(ResourceInterface $resource)
    {
        $definition = new Definition($resource->getDomainManager(), [
            new Reference('lug.resource.'.$resource->getName()),
            new Reference('lug.resource.domain.event_dispatcher'),
            new Reference('lug.manager.'.$resource->getName()),
            new Reference('lug.repository.'.$resource->getName()),
        ]);

        $definition->addTag('lug.domain_manager', ['resource' => $resource->getName()]);

        return $definition;
    }
1138966
private function load($resource, string $type = null): array
    {
        if (null === $this->loader) {
            throw new \BadMethodCallException('Cannot import other routing resources: you must pass a LoaderInterface when constructing RouteCollectionBuilder.');
        }

        if ($this->loader->supports($resource, $type)) {
            $collections = $this->loader->load($resource, $type);

            return \is_array($collections) ? $collections : [$collections];
        }

        if (null === $resolver = $this->loader->getResolver()) {
            throw new LoaderLoadException($resource, null, null, null, $type);
        }

        if (false === $loader = $resolver->resolve($resource, $type)) {
            throw new LoaderLoadException($resource, null, null, null, $type);
        }

        $collections = $loader->load($resource, $type);

        return \is_array($collections) ? $collections : [$collections];
    }
41638
protected static function reqGetResourceRelationships(ContextInterface $context): array
    {
        assert(static::reqHasResourceRelationships($context));

        $value = $context->getRequest()->get(RequestProperties::REQ_RESOURCE_RELATIONSHIPS);

        assert(is_array($value));

        return $value;
    }
724914
public function findAllForGroup($groupId)
    {
        if (!$groupId) {
            return [];
        }

        if (!is_array($groupId)) {
            $groupId = [$groupId];
        }

        $cacheKey = join('_', $groupId);

        $permissions = Cache::remember($cacheKey, function () use ($groupId) {
            return $this
                ->find('list', [
                    'keyField' => 'path',
                    'valueField' => 'allowed'
                ])
                ->where([
                    'group_id IN' => $groupId,
                    'allowed >' => 0
                ])
                ->order('allowed DESC')
                ->hydrate(false)
                ->toArray();
        }, 'wasabi/core/group_permissions');

        return $permissions;
    }
10828
protected function convertRole(RoleInterface $role)
    {
        $roleData['id'] = $role->getId();
        $roleData['name'] = $role->getName();
        $roleData['identifier'] = $role->getIdentifier();
        $roleData['system'] = $role->getSystem();
        $roleData['permissions'] = [];

        $permissions = $role->getPermissions();
        if (!empty($permissions)) {
            foreach ($permissions as $permission) {
                /* @var Permission $permission */
                $roleData['permissions'][] = [
                    'id' => $permission->getId(),
                    'context' => $permission->getContext(),
                    'module' => $permission->getModule(),
                    'permissions' => $this->get('sulu_security.mask_converter')
                        ->convertPermissionsToArray($permission->getPermissions()),
                ];
            }
        }

        $securityType = $role->getSecurityType();
        if ($securityType) {
            $roleData['securityType'] = [
                'id' => $securityType->getId(),
                'name' => $securityType->getName(),
            ];
        }

        return $roleData;
    }
320217
public function getCurrentPermissionArray(ResourceNode $resourceNode)
    {
        $currentRoles = $this->tokenStorage->getToken()->getRoles();

        $roleNames = array_map(function (RoleInterface $roleName) {
            return $roleName->getRole();
        }, $currentRoles);

        $creatable = [];
        if ($this->isManager($resourceNode)) {
            /** @var ResourceType[] $resourceTypes */
            $resourceTypes = $this->om->getRepository('ClarolineCoreBundle:Resource\ResourceType')->findAll();

            foreach ($resourceTypes as $resourceType) {
                $creatable[] = $resourceType->getName();
            }

            $perms = array_fill_keys(array_values($this->maskManager->getPermissionMap($resourceNode->getResourceType())), true);
        } else {
            $creatable = $this->getCreatableTypes($roleNames, $resourceNode);

            $perms = $this->maskManager->decodeMask(
                $this->rightsRepo->findMaximumRights($roleNames, $resourceNode),
                $resourceNode->getResourceType()
            );
        }

        return array_merge($perms, ['create' => $creatable]);
    }
545173
protected function execute(ApiResourceInterface $resource)
    {
        $client = $resource->getHttpClient();

        if (is_null($options = $this->requestOptions())) {
            return $client->request($this->requestMethod(), $this->requestUrl($resource));
        }

        return $client->request($this->requestMethod(), $this->requestUrl($resource), $options);
    }
653613
private function getProperties(\SimpleXMLElement $resource): array
    {
        $properties = [];
        foreach ($resource->property as $property) {
            $properties[(string) $property['name']] = [
                'description' => $this->phpize($property, 'description', 'string'),
                'readable' => $this->phpize($property, 'readable', 'bool'),
                'writable' => $this->phpize($property, 'writable', 'bool'),
                'readableLink' => $this->phpize($property, 'readableLink', 'bool'),
                'writableLink' => $this->phpize($property, 'writableLink', 'bool'),
                'required' => $this->phpize($property, 'required', 'bool'),
                'identifier' => $this->phpize($property, 'identifier', 'bool'),
                'iri' => $this->phpize($property, 'iri', 'string'),
                'attributes' => $this->getAttributes($property, 'attribute'),
                'subresource' => $property->subresource ? [
                    'collection' => $this->phpize($property->subresource, 'collection', 'bool'),
                    'resourceClass' => $this->phpize($property->subresource, 'resourceClass', 'string'),
                    'maxDepth' => $this->phpize($property->subresource, 'maxDepth', 'integer'),
                ] : null,
            ];
        }

        return $properties;
    }
1221239
protected function gatherPermissions(UserInterface $user = null)
    {
        $user = $user ?: $this->currentUser();
        $roles = $user->getRoles();
        $permissions = $user->getPermissions();

        foreach ($roles as $role) {
            if (isset($this->roleDictionary[$role])) {
                $permissions = array_merge($permissions, $this->roleDictionary[$role]);
            }
        }

        return $permissions;
    }
965871
public function listAllowedByClass($resourceClass, string $action = ''): array
    {
        $permissions = $this->groupPermissions->getResourcePermissionsByClass($resourceClass);
        $permitted = [];
        foreach ($permissions as $permission) {
            if (!$action || $permission->can($action)) {
                $permitted[] = $permission->getResourceId();
            }
        }

        return array_unique($permitted);
    }
248618
public function equals(ResourceInterface $resource) {
		if ($this->hasIdentification() === false || $resource->getResource()->hasIdentification() === false) {
			throw new Exception('can not compare resources if identification is missing');
		}
		
		return ($this->getIdentificationKey() === $resource->getResource()->getIdentificationKey());
	}
355147
public function addGroup(EventInterface $event) {
        $accessControl = $event->getAccessControl();
        if (!($accessControl instanceof MutableAdapterInterface)) {
            throw new ResourceException('Access control adapter is immutable', 405);
        }

        $request = $event->getRequest();
        $route = $request->getRoute();
        $groupName = $route->get('group');

        $group = $accessControl->getGroup($groupName);
        $groupExists = !empty($group);

        $resources = json_decode($request->getContent(), true);

        if (!is_array($resources)) {
            throw new ResourceException('Invalid data. Array of resource strings is expected', 400);
        }

        foreach ($resources as $resource) {
            if (!is_string($resource)) {
               throw new ResourceException('Invalid value in the resources array. Only strings are allowed', 400);
            }
        }

        if ($groupExists) {
            $accessControl->updateResourceGroup($groupName, $resources);
        } else {
            $accessControl->addResourceGroup($groupName, $resources);
        }

        $response = $event->getResponse();
        $response->setStatusCode($groupExists ? 200 : 201);
    }
638968
protected function serialize(ResourceInterface $resource, $data)
    {
        // Get the serializer from the resource, or use the default.
        $serializer = $resource->getSerializer() ?? $this->getSerializer();
        
        if ($serializer instanceof SerializerInterface) {
            if ($resource instanceof Collection) {
                if ($data === null) {
                    return $serializer->nullCollection();
                }
                $data = $serializer->collection($resource->getResourceKey(), $data);
                if ($resource->hasPaginator()) {
                    $data = array_merge($data, $serializer->paginator($resource->getPaginator()));
                }
            } elseif ($resource instanceof Item) {
                if ($data === null) {
                    return $serializer->nullItem();
                }
                $data = $serializer->item($resource->getResourceKey(), $data);
            }
        } elseif (\is_callable($serializer)) {
            // Serialize via a callable/closure
            $data = $serializer($resource->getResourceKey(), $data);
        }
       
        return $data;
    }
649841
public function getStrings(\core_kernel_classes_Resource $resource)
    {
        $tokenizer = $this->getItemContentTokenizer($resource);
        if (is_null($tokenizer)) {
            return [];
        }
        return $tokenizer->getStrings($resource);
    }