/**
  * @param object $entity
  *
  * @return MetaInformation
  *
  * @throws \RuntimeException if no declaration for document found in $entity
  */
 public function loadInformation($entity)
 {
     $className = $this->getClass($entity);
     if (!is_object($entity)) {
         $reflectionClass = new \ReflectionClass($className);
         if (!$reflectionClass->isInstantiable()) {
             throw new \RuntimeException(sprintf('cannot instantiate entity %s', $className));
         }
         $entity = $reflectionClass->newInstanceWithoutConstructor();
     }
     if (!$this->annotationReader->hasDocumentDeclaration($entity)) {
         throw new \RuntimeException(sprintf('no declaration for document found in entity %s', $className));
     }
     $metaInformation = new MetaInformation();
     $metaInformation->setEntity($entity);
     $metaInformation->setClassName($className);
     $metaInformation->setDocumentName($this->getDocumentName($className));
     $metaInformation->setFieldMapping($this->annotationReader->getFieldMapping($entity));
     $metaInformation->setFields($this->annotationReader->getFields($entity));
     $metaInformation->setRepository($this->annotationReader->getRepository($entity));
     $metaInformation->setIdentifier($this->annotationReader->getIdentifier($entity));
     $metaInformation->setBoost($this->annotationReader->getEntityBoost($entity));
     $metaInformation->setSynchronizationCallback($this->annotationReader->getSynchronizationCallback($entity));
     $metaInformation->setIndex($this->annotationReader->getDocumentIndex($entity));
     $metaInformation->setIsDoctrineEntity($this->annotationReader->isDoctrineEntity($entity));
     return $metaInformation;
 }
예제 #2
0
 /**
  * @param object $entity
  *
  * @return MetaInformation
  *
  * @throws \RuntimeException if no declaration for document found in $entity
  */
 public function loadInformation($entity)
 {
     $className = $this->getClass($entity);
     if (!is_object($entity)) {
         $entity = new $className();
     }
     if (!$this->annotationReader->hasDocumentDeclaration($entity)) {
         throw new \RuntimeException(sprintf('no declaration for document found in entity %s', $className));
     }
     $metaInformation = new MetaInformation();
     $metaInformation->setEntity($entity);
     $metaInformation->setClassName($className);
     $metaInformation->setDocumentName($this->getDocumentName($className));
     $metaInformation->setFieldMapping($this->annotationReader->getFieldMapping($entity));
     $metaInformation->setFields($this->annotationReader->getFields($entity));
     $metaInformation->setRepository($this->annotationReader->getRepository($entity));
     $metaInformation->setIdentifier($this->annotationReader->getIdentifier($entity));
     $metaInformation->setBoost($this->annotationReader->getEntityBoost($entity));
     $metaInformation->setSynchronizationCallback($this->annotationReader->getSynchronizationCallback($entity));
     $metaInformation->setIndex($this->annotationReader->getDocumentIndex($entity));
     return $metaInformation;
 }
예제 #3
0
 public function testGetCallback_NoCallbackDefined()
 {
     $reader = new AnnotationReader();
     $callback = $reader->getSynchronizationCallback(new ValidTestEntity());
     $this->assertEquals('', $callback);
 }
예제 #4
0
 /**
  * @test
  */
 public function readAnnotationsFromMultipleClassHierarchy()
 {
     $reader = new AnnotationReader();
     $fields = $reader->getFields(new ChildEntity2());
     $this->assertEquals(4, count($fields));
 }
예제 #5
0
 /**
  * @test
  */
 public function checkIfPlainObjectIsDoctrineEntity()
 {
     $this->assertTrue($this->reader->isDoctrineEntity(new ValidTestEntity()), 'is a doctrine entity');
 }