getResourcesMnemonic() public static method

This method excludes disabled resources.
public static getResourcesMnemonic ( ) : array
return array Returns all resources looks like array(resourceId => mnemonicIndex)
示例#1
0
 /**
  * Provider method for testGet() test
  */
 public function providerGet()
 {
     $refl = new \ReflectionClass('Scalr\\Acl\\Acl');
     $arguments = array();
     //Fetches all resources which have been defined in the Acl class except excluded
     foreach (Acl::getResourcesMnemonic() as $resourceId => $mnemonicName) {
         $arguments[] = array($resourceId);
     }
     return $arguments;
 }
示例#2
0
 /**
  * This test is used mapping from Fixtures/{self::TEST_DATA_FILE} yaml file
  *
  * @test
  */
 public function testIsImposedRestriction()
 {
     $rm = Acl::getResourcesMnemonic();
     //We have to use provider in this way because of we need to skip test and throw assertion from it
     $providerData = $this->providerIsImposedRestriction();
     foreach ($providerData as $opt) {
         $uri = $opt[0];
         $granted = $opt[1];
         $resourceId = $opt[2];
         $permissionId = isset($opt[3]) ? $opt[3] : null;
         $options = isset($opt[4]) ? $opt[4] : array();
         $this->setCatchOnlyPermission($resourceId, $permissionId);
         $this->assertThatPermission($granted, $uri, $options, sprintf("Resource:%s, Permission:%s, URI:%s", isset($rm[$resourceId]) ? $rm[$resourceId] : $resourceId, isset($permissionId) ? $permissionId : 'null', $uri));
     }
 }
 /**
  * Gets allowed resources
  *
  * Current exclude filters will be applied
  *
  * @param   bool    $mnemonicIndexes  Should it use mnemonic indexes for key or integer ids.
  * @return  array   Returns array looks like array((mnemonicIndex|resource_id) => (null | array(permission_id => 1))
  */
 public function getAllowedArray($mnemonicIndexes = false)
 {
     $ret = array();
     $resourceNames = Acl::getResourcesMnemonic();
     foreach (Resource\Definition::getAll() as $resource) {
         /* @var $resource Resource\ResourceObject */
         if (!$this->isAllowed($resource->getResourceId())) {
             continue;
         }
         $rec = array();
         foreach ($resource->getPermissions() as $permissionId => $description) {
             if ($this->isAllowed($resource->getResourceId(), $permissionId)) {
                 $rec[$permissionId] = 1;
             }
         }
         $id = $mnemonicIndexes ? $resourceNames[$resource->getResourceId()] : $resource->getResourceId();
         $ret[$id] = empty($rec) ? 1 : $rec;
     }
     return $ret;
 }
示例#4
0
 /**
  * Gets allowed resources
  *
  * Current exclude filters will be applied
  *
  * @param   bool    $mnemonicIndexes  Should it use mnemonic indexes for key or integer ids.
  * @return  array   Returns array looks like array((mnemonicIndex|resource_id) => (null | array(permission_id => 1))
  */
 public function getAllowedArray($mnemonicIndexes = false)
 {
     $ret = [];
     $resourceNames = Acl::getResourcesMnemonic();
     foreach (Resource\Definition::getAll() as $resource) {
         /* @var $resource Resource\ResourceObject */
         if (!$this->isAllowed($resource->getResourceId())) {
             continue;
         }
         $rec = [];
         $aPerm = [];
         foreach ($resource->getPermissions() as $permissionId => $description) {
             if ($this->isAllowed($resource->getResourceId(), $permissionId)) {
                 $aPerm[$permissionId] = 1;
             }
         }
         if (!empty($aPerm)) {
             $rec['permissions'] = $aPerm;
         }
         if ($mode = $resource->getMode()) {
             $modeMapping = $mode->getMapping();
             $rec['mode'] = $this->getResourceMode($resource->getResourceId());
             if (isset($modeMapping[(int) $rec['mode']])) {
                 $rec['mode'] = $modeMapping[(int) $rec['mode']]->constName;
             }
         }
         $id = $mnemonicIndexes ? $resourceNames[$resource->getResourceId()] : $resource->getResourceId();
         $ret[$id] = empty($rec) ? 1 : $rec;
     }
     return $ret;
 }