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;
 }
Пример #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;
 }
Пример #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;
 }