getAllResources() final public static method

Returns a list of all resources available, including those which involves access control
final public static getAllResources ( ) : array
return array
示例#1
0
 /**
  * Figure out which resources we have available and subscribe to them
  *
  * @param EventInterface $event
  */
 public function subscribe(EventInterface $event)
 {
     $resources = Resource::getAllResources();
     if ($this->params['additionalResources']) {
         $resources = array_merge($resources, $this->params['additionalResources']);
     }
     $events = [];
     foreach ($resources as $resource) {
         $events[$resource] = ['checkAccess' => 500];
     }
     $manager = $event->getManager();
     $manager->addCallbacks($event->getHandler(), $events);
 }
示例#2
0
 public function testMethodsReturnsArrays()
 {
     $this->assertInternalType('array', Resource::getReadOnlyResources());
     $this->assertInternalType('array', Resource::getReadWriteResources());
     $this->assertInternalType('array', Resource::getAllResources());
 }
示例#3
0
 /**
  * Ask user which specific resources the public key should have access to
  *
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  * @return array
  */
 private function askForSpecificResources(InputInterface $input, OutputInterface $output)
 {
     $resources = Resource::getAllResources();
     sort($resources);
     $question = new ChoiceQuestion('Which resources should the public key have access to? (comma-separated) ', $resources);
     $question->setMultiselect(true);
     return $this->getHelper('question')->ask($input, $output, $question);
 }
示例#4
0
 /**
  * @covers ImboCli\Command\AddPublicKey::execute
  * @covers ImboCli\Command\AddPublicKey::askForAnotherAclRule
  * @covers ImboCli\Command\AddPublicKey::askForCustomResources
  */
 public function testPromtpsForListOfCustomResourcesIfOptionIsSelected()
 {
     $allResources = Resource::getAllResources();
     sort($allResources);
     $this->adapter->expects($this->once())->method('addAccessRule')->with('foo', ['resources' => ['foo.read', 'bar.write'], 'users' => '*']);
     $this->adapter->expects($this->once())->method('addKeyPair')->with('foo', 'bar');
     $helper = $this->command->getHelper('question');
     $helper->setInputStream($this->getInputStream(['4', 'foo.read,bar.write', '*', 'n']));
     $commandTester = new CommandTester($this->command);
     $commandTester->execute(['publicKey' => 'foo', 'privateKey' => 'bar']);
 }