Esempio n. 1
0
 /**
  * Returns true if and only if the Resource exists in the ACL
  *
  * The $resource parameter can either be a Resource or a Resource identifier.
  *
  * @param  \Zend\Permissions\Acl\Resource\ResourceInterface|string $resource
  *
  * @return bool
  */
 public function hasResource($resource)
 {
     if (is_string($resource)) {
         return $this->resourceProvider->hasResource($resource);
     }
     if ($resource instanceof ResourceInterface) {
         return $this->resourceProvider->hasResource($resource->getResourceId());
     }
     return false;
 }
Esempio n. 2
0
 /**
  * getResourceStack
  *
  * @param AclResource $resource
  * @param array       $resources
  * @param int         $nestLevel
  *
  * @return array
  * @throws RcmUserException
  */
 public function getResourceStack(AclResource $resource, $resources = [], $nestLevel = 0)
 {
     if ($nestLevel > $this->maxResourceNesting) {
         throw new RcmUserException('Max resource nesting exceeded, max nesting level is ' . $this->maxResourceNesting);
     }
     $tempResource = [$resource->getResourceId() => $resource];
     $resources = $tempResource + $resources;
     $parentResourceId = $resource->getParentResourceId();
     $hasParent = $parentResourceId !== null;
     if ($hasParent) {
         $parentResource = $this->resourceProvider->getResource($parentResourceId);
         $nestLevel++;
         return $this->getResourceStack($parentResource, $resources, $nestLevel);
     }
     return $resources;
 }
 /**
  * getNamespacedResources
  *
  * @param null $namespaceSeparator
  *
  * @return array
  */
 public function getNamespacedResources($namespaceSeparator = null)
 {
     $aclResources = [];
     $resources = $this->resourceProvider->getResources();
     foreach ($resources as $resource) {
         $ns = $this->createNamespaceId($resource, $resources, $namespaceSeparator);
         $aclResources[$ns] = $resource;
     }
     ksort($aclResources);
     return $aclResources;
 }
 /**
  * add
  *
  * @param ResourceProviderInterface $resourceProvider
  *
  * @return void
  */
 public function add(ResourceProviderInterface $resourceProvider)
 {
     $this->resourceProviders[$resourceProvider->getProviderId()] = $resourceProvider;
 }
Esempio n. 5
0
 /**
  * @deprecated Use Registered 'RcmUser\Acl\ResourceProvider' service
  * getAllResources - All resources
  * returns a list of all resources
  * This is used for displays or utilities only
  * should not be used for ACL checks
  *
  * @param bool $refresh refresh
  *
  * @return array
  * @throws \RcmUser\Exception\RcmUserException
  */
 public function getAllResources($refresh = false)
 {
     return $this->resourceProvider->getResources();
 }