Exemplo n.º 1
0
 protected function getClassMetadata()
 {
     $classMetadata = new ClassMetadata('Indigo\\Fieldset\\Stubs\\Entity');
     $propertMetadata = new PropertyMetadata('Indigo\\Fieldset\\Stubs\\Entity', 'prop');
     $classMetadata->addPropertyMetadata($propertMetadata);
     return $classMetadata;
 }
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new ClassMetadata($class->getName());
     foreach ($class->getProperties() as $reflectionProperty) {
         foreach ($this->reader->getPropertyAnnotations($reflectionProperty) as $fieldAnnot) {
             $propertyMetadata = new PropertyMetadata($class->getName(), $reflectionProperty->getName());
             if ($fieldAnnot instanceof BRIDGE\Entity) {
                 /**
                  * @var BRIDGE\Entity $fieldAnnot
                  */
                 $propertyMetadata->targetObject = $fieldAnnot->targetEntity;
                 $propertyMetadata->targetManager = $fieldAnnot->entityManager;
                 $propertyMetadata->type = 'dbal';
                 $classMetadata->addPropertyMetadata($propertyMetadata);
             }
             if ($fieldAnnot instanceof BRIDGE\Document) {
                 /**
                  * @var BRIDGE\Document $fieldAnnot
                  */
                 $propertyMetadata->targetObject = $fieldAnnot->targetDocument;
                 $propertyMetadata->targetManager = $fieldAnnot->documentManager;
                 $propertyMetadata->type = 'odm';
                 $classMetadata->addPropertyMetadata($propertyMetadata);
             }
         }
     }
     return $classMetadata;
 }
Exemplo n.º 3
0
 public function testIsFresh()
 {
     $ref = new \ReflectionClass('Metadata\\Tests\\Fixtures\\TestObject');
     touch($ref->getFilename());
     sleep(2);
     $metadata = new ClassMetadata($ref->name);
     $metadata->fileResources[] = $ref->getFilename();
     $this->assertTrue($metadata->isFresh());
     sleep(2);
     clearstatcache($ref->getFilename());
     touch($ref->getFilename());
     $this->assertFalse($metadata->isFresh());
 }
Exemplo n.º 4
0
 /**
  * {@inheritdoc}
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new ClassMetadata($name = $class->name);
     foreach ($class->getProperties() as $property) {
         if ($property->class !== $name) {
             continue;
         }
         if ($filters = $this->readPropertyFilters($property)) {
             $propertyMetadata = new PropertyMetadata($name, $property->getName());
             $propertyMetadata->setFilters($filters);
             $classMetadata->addPropertyMetadata($propertyMetadata);
         }
     }
     return $classMetadata;
 }
Exemplo n.º 5
0
 /**
  * @param \ReflectionClass $class
  *
  * @return \Metadata\ClassMetadata
  */
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new ClassMetadata($class->getName());
     foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $reflectionMethod) {
         if (false === strpos($reflectionMethod->getName(), 'Action')) {
             continue;
         }
         if ($reflectionMethod->isAbstract()) {
             continue;
         }
         $methodMetadata = new ActionMetadata($class->getName(), $reflectionMethod->getName());
         $annotations = $this->reader->getMethodAnnotations($reflectionMethod);
         foreach ($annotations as $annotation) {
             if ($annotation instanceof \BackBee\Rest\Controller\Annotations\QueryParam) {
                 $data = array('name' => $annotation->name, 'key' => $annotation->key ? $annotation->key : $annotation->name, 'default' => $annotation->default, 'description' => $annotation->description, 'requirements' => $annotation->requirements);
                 $methodMetadata->queryParams[] = $data;
             } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\RequestParam) {
                 $data = array('name' => $annotation->name, 'key' => $annotation->key ? $annotation->key : $annotation->name, 'default' => $annotation->default, 'description' => $annotation->description, 'requirements' => $annotation->requirements);
                 $methodMetadata->requestParams[] = $data;
             } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\Pagination) {
                 $methodMetadata->default_start = $annotation->default_start;
                 $methodMetadata->default_count = $annotation->default_count;
                 $methodMetadata->max_count = $annotation->max_count;
                 $methodMetadata->min_count = $annotation->min_count;
             } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\ParamConverter) {
                 $methodMetadata->param_converter_bag[] = $annotation;
             } elseif ($annotation instanceof \BackBee\Rest\Controller\Annotations\Security) {
                 $methodMetadata->security[] = $annotation;
             }
         }
         $classMetadata->addMethodMetadata($methodMetadata);
     }
     return $classMetadata;
 }
Exemplo n.º 6
0
 /**
  * @param string $str
  */
 public function unserialize($str)
 {
     $data = unserialize($str);
     // prevent errors if not all key's are set
     @(list($this->id, $this->parent, $this->scope, $this->public, $this->abstract, $this->tags, $this->arguments, $this->methodCalls, $this->lookupMethods, $this->properties, $this->initMethod, $parentStr, $this->environments, $this->decorates, $this->decoration_inner_name, $this->deprecated, $this->initMethods, ) = $data);
     parent::unserialize($parentStr);
 }
Exemplo n.º 7
0
 public function unserialize($str)
 {
     $data = unserialize($str);
     list($this->id, $this->parent, $this->scope, $this->public, $this->abstract, $this->tags, $this->arguments, $this->methodCalls, $this->lookupMethods, $this->properties, $this->initMethod, $parentStr) = $data;
     if (isset($data[12])) {
         $this->environments = $data[12];
     }
     parent::unserialize($parentStr);
 }
 public function loadMetadataForClass(\ReflectionClass $class)
 {
     $classMetadata = new ClassMetadata($name = $class->name);
     $classMetadata->fileResources[] = $class->getFilename();
     $propertiesMetadata = array();
     $propertiesAnnotations = array();
     foreach ($class->getProperties() as $property) {
         if ($property->class !== $name) {
             continue;
         }
         $propertiesMetadata[] = new PropertyMetadata($name, $property->getName());
         $propertiesAnnotations[] = $this->reader->getPropertyAnnotations($property);
     }
     foreach ($propertiesMetadata as $propertyKey => $propertyMetadata) {
         $propertyAnnotations = $propertiesAnnotations[$propertyKey];
         foreach ($propertyAnnotations as $annot) {
             if ($annot instanceof ExcludeIf) {
                 $propertyMetadata->exclusionExpression = $annot->expression;
             }
         }
         $classMetadata->addPropertyMetadata($propertyMetadata);
     }
     return $classMetadata;
 }
Exemplo n.º 9
0
 public function unserialize($str)
 {
     list($this->id, $this->parent, $this->scope, $this->public, $this->abstract, $this->tags, $this->arguments, $this->methodCalls, $this->lookupMethods, $this->properties, $this->initMethod, $parentStr) = unserialize($str);
     parent::unserialize($parentStr);
 }