Exemple #1
0
 public function testBuildSkipsModuleIfControllerDirConfigIsIncorrect()
 {
     $modules = ['nec' => ['className' => 'NotExisting\\Controller', 'path' => 'not/existing/path']];
     $this->obj = new Builder($modules);
     $build = $this->obj->build();
     $this->assertEmpty($build);
 }
Exemple #2
0
 /**
  * Clears stored list of resources with their accesses and recreates it based on ACL annotations in controllers.
  *
  * Usage:
  *   vegas:security_acl:role build
  */
 public function buildAction()
 {
     //clears collection before build
     $acl = $this->getAcl();
     $acl->removeResources();
     $acl->removeResourceAccesses();
     $config = $this->getDI()->get('config');
     $predefinedResources = isset($config['acl']) ? $config['acl']->toArray() : $this->predefinedResources;
     $resourceBuilder = new Builder($this->getDI()->get('modules'), $predefinedResources);
     $aclResources = $resourceBuilder->build();
     $resourceManager = $this->getAcl()->getResourceManager();
     foreach ($aclResources as $aclResource) {
         if (empty($aclResource)) {
             continue;
         }
         $resourceManager->add($aclResource['name'], $aclResource['description'], $aclResource['accessList'], isset($aclResource['scope']) ? $aclResource['scope'] : '');
     }
     $this->putText('Success.');
 }