Example #1
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $annotations = $this->reader->getClassAnnotations($class);
     if (0 === count($annotations)) {
         return null;
     }
     $classMetadata = new ClassMetadata($class->getName());
     $classMetadata->fileResources[] = $class->getFilename();
     foreach ($annotations as $annotation) {
         if ($annotation instanceof Annotation\Relation) {
             $classMetadata->addRelation(new Relation($annotation->name, $this->createHref($annotation->href), $this->createEmbedded($annotation->embedded), $annotation->attributes ?: array(), $this->createExclusion($annotation->exclusion)));
         } elseif ($annotation instanceof Annotation\RelationProvider) {
             $classMetadata->addRelationProvider(new RelationProvider($annotation->name));
         }
     }
     if (0 === count($classMetadata->getRelations()) && 0 === count($classMetadata->getRelationProviders())) {
         return null;
     }
     return $classMetadata;
 }
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $annotations = $this->reader->getClassAnnotations($class);
     if (0 === count($annotations)) {
         return null;
     }
     $classMetadata = new ClassMetadata($class->getName());
     $classMetadata->fileResources[] = $class->getFilename();
     foreach ($annotations as $annotation) {
         if ($annotation instanceof Annotation\Relation) {
             $href = $annotation->href;
             if ($href instanceof Annotation\Route) {
                 $href = new Route($href->name, $href->parameters, $href->absolute, $href->generator);
             }
             $embed = $annotation->embed;
             if ($embed instanceof Annotation\Embed) {
                 $embedExclusion = $embed->exclusion;
                 if (null !== $embedExclusion) {
                     $embedExclusion = $this->parseExclusion($embedExclusion);
                 }
                 $embed = new Embed($embed->content, $embed->xmlElementName, $embedExclusion);
             }
             $exclusion = $annotation->exclusion;
             if (null !== $exclusion) {
                 $exclusion = $this->parseExclusion($exclusion);
             }
             $classMetadata->addRelation(new Relation($annotation->name, $href, $embed, $annotation->attributes ?: array(), $exclusion));
         } elseif ($annotation instanceof Annotation\RelationProvider) {
             $classMetadata->addRelationProvider(new RelationProvider($annotation->name));
         }
     }
     if (0 === count($classMetadata->getRelations()) && 0 === count($classMetadata->getRelationProviders())) {
         return null;
     }
     return $classMetadata;
 }