public function loadMetadataForClass(ReflectionClass $reflection)
 {
     $metadata = new ClassMetadata($reflection->name);
     $classPreAuthorize = $this->reader->getClassAnnotation($reflection, 'JMS\\SecurityExtraBundle\\Annotation\\PreAuthorize');
     $classAnnotations = $this->reader->getClassAnnotations($reflection);
     foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED) as $method) {
         // check if the method was defined on this class
         if ($method->getDeclaringClass()->name !== $reflection->name) {
             continue;
         }
         $annotations = $this->reader->getMethodAnnotations($method);
         if ($classAnnotations) {
             foreach ($classAnnotations as $classAnnotation) {
                 if ($classAnnotation instanceof SecureParam) {
                     $annotations[] = $classAnnotation;
                 }
             }
         }
         if (!$annotations && !$classPreAuthorize) {
             continue;
         }
         if (null !== ($methodMetadata = $this->convertMethodAnnotations($method, $annotations, $classPreAuthorize))) {
             $metadata->addMethodMetadata($methodMetadata);
         }
     }
     return $metadata;
 }
Exemplo n.º 2
0
 public function loadMetadataForClass(ReflectionClass $reflection)
 {
     $metadata = new ClassMetadata($reflection->getName());
     foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC | ReflectionMethod::IS_PROTECTED) as $method) {
         // check if the method was defined on this class
         if ($method->getDeclaringClass()->getName() !== $reflection->getName()) {
             continue;
         }
         $annotations = $this->reader->getMethodAnnotations($method);
         if ($annotations && null !== ($methodMetadata = $this->convertMethodAnnotations($method, $annotations))) {
             $metadata->addMethodMetadata($methodMetadata);
         }
     }
     return $metadata;
 }
Exemplo n.º 3
0
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $metadata = new ClassMetadata($class->name);
     foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED) as $method) {
         if ($method->getDeclaringClass()->name !== $class->name) {
             continue;
         }
         $expression = null;
         if (null !== ($notation = $this->getControllerNotation($method))) {
             $expression = $this->getExpressionForSignature($notation);
         }
         if (null === $expression && null === ($expression = $this->getExpressionForSignature($method->class . '::' . $method->name))) {
             continue;
         }
         $methodMetadata = new MethodMetadata($method->class, $method->name);
         $methodMetadata->roles = array(new Expression($expression));
         $metadata->addMethodMetadata($methodMetadata);
     }
     if (!$metadata->methodMetadata) {
         return null;
     }
     return $metadata;
 }
Exemplo n.º 4
0
 private function collectServiceMetadata()
 {
     $this->metadata = new ServiceMetadata();
     $classMetadata = null;
     foreach ($this->hierarchy as $reflectionClass) {
         if (null === $classMetadata) {
             $classMetadata = new ClassMetadata($reflectionClass->getName());
         }
         if (null !== ($aMetadata = $this->driver->loadMetadataForClass($reflectionClass))) {
             if ($reflectionClass->isInterface()) {
                 $classMetadata->merge($aMetadata);
             } else {
                 $this->metadata->addClassMetadata($classMetadata);
                 $classMetadata = $aMetadata;
             }
         }
     }
     $this->metadata->addClassMetadata($classMetadata);
 }