Ejemplo n.º 1
0
 /**
  * Loads ACL annotations from PHP files
  *
  * @param AclAnnotationStorage $storage
  */
 public function load(AclAnnotationStorage $storage)
 {
     $configLoader = OroSecurityExtension::getAclAnnotationLoader();
     $resources = $configLoader->load();
     foreach ($resources as $resource) {
         foreach ($resource->data as $file) {
             $className = $this->getClassName($file);
             if ($className !== null) {
                 $reflection = $this->getReflectionClass($className);
                 // read annotations from class
                 $annotation = $this->reader->getClassAnnotation($reflection, self::ANNOTATION_CLASS);
                 if ($annotation) {
                     $storage->add($annotation, $reflection->getName());
                 } else {
                     $ancestor = $this->reader->getClassAnnotation($reflection, self::ANCESTOR_CLASS);
                     if ($ancestor) {
                         $storage->addAncestor($ancestor, $reflection->getName());
                     }
                 }
                 // read annotations from methods
                 foreach ($reflection->getMethods() as $reflectionMethod) {
                     $annotation = $this->reader->getMethodAnnotation($reflectionMethod, self::ANNOTATION_CLASS);
                     if ($annotation) {
                         $storage->add($annotation, $reflection->getName(), $reflectionMethod->getName());
                     } else {
                         $ancestor = $this->reader->getMethodAnnotation($reflectionMethod, self::ANCESTOR_CLASS);
                         if ($ancestor) {
                             $storage->addAncestor($ancestor, $reflection->getName(), $reflectionMethod->getName());
                         }
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Loads ACL annotations from config files
  *
  * @param AclAnnotationStorage $storage
  */
 public function load(AclAnnotationStorage $storage)
 {
     $configLoader = OroSecurityExtension::getAclConfigLoader();
     $resources = $configLoader->load();
     foreach ($resources as $resource) {
         foreach ($resource->data as $id => $data) {
             $data['id'] = $id;
             $storage->add(new AclAnnotation($data));
             if (isset($data['bindings'])) {
                 foreach ($data['bindings'] as $binding) {
                     $storage->addBinding($id, isset($binding['class']) ? $binding['class'] : null, isset($binding['method']) ? $binding['method'] : null);
                 }
             }
         }
     }
 }