/**
  * @inheritdoc
  */
 protected function wakeupReflection(ClassMetadata $class, ReflectionService $reflService)
 {
     $class->reflClass = $reflService->getClass($class->name);
     foreach ($class->fieldMappings as $fieldName => $mapping) {
         $class->reflFields[$fieldName] = $reflService->getAccessibleProperty($class->name, $fieldName);
     }
 }
 protected function initializeReflection(ClassMetadata $class, ReflectionService $reflService)
 {
     $class->reflClass = $reflService->getClass($class->name);
     if ($class->reflClass) {
         foreach ($class->reflClass->getProperties() as $property) {
             $class->mapField(['fieldName' => $property->getName()]);
         }
     }
 }
 /**
  * Returns the class names of additional entities that are directly associated with
  * one of the entities that is explicitly mentioned in the given configuration.
  *
  * @param Configuration $config
  * @param string[] $entityClasses Classes whose associations are checked.
  * @return string[] Associated entity classes.
  */
 protected function getDirectlyAssociatedEntities(Configuration $config, $entityClasses)
 {
     if (count($entityClasses) === 0) {
         return array();
     }
     $associatedEntities = array();
     foreach ($entityClasses as $entityClass) {
         /* @var $entityClass string */
         $metadata = new ClassMetadata($entityClass);
         $metadata->initializeReflection($this->reflectionService);
         $config->getMetadataDriverImpl()->loadMetadataForClass($entityClass, $metadata);
         foreach ($metadata->getAssociationNames() as $name) {
             /* @var $name string */
             $associatedEntity = $metadata->getAssociationTargetClass($name);
             $associatedEntities[] = $metadata->fullyQualifiedClassName($associatedEntity);
         }
         if (count($metadata->discriminatorMap) > 0) {
             $childClasses = array_values($metadata->discriminatorMap);
             $associatedEntities = array_merge($associatedEntities, $childClasses);
         }
         // Add parent classes that are involved in some kind of entity inheritance.
         foreach ($this->reflectionService->getParentClasses($entityClass) as $parentClass) {
             if (!$config->getMetadataDriverImpl()->isTransient($parentClass)) {
                 $associatedEntities[] = $parentClass;
             }
         }
     }
     return array_unique($associatedEntities);
 }
Example #4
0
 /**
  * Validate lifecycle callbacks
  *
  * @param ReflectionService $reflService
  *
  * @throws MappingException if a declared callback does not exist
  */
 public function validateLifecycleCallbacks(ReflectionService $reflService)
 {
     foreach ($this->lifecycleCallbacks as $callbacks) {
         foreach ($callbacks as $callbackFuncName) {
             if (!$reflService->hasPublicMethod($this->name, $callbackFuncName)) {
                 throw MappingException::lifecycleCallbackMethodNotFound($this->name, $callbackFuncName);
             }
         }
     }
 }
Example #5
0
 /**
  * Initializes a new ClassMetadata instance that will hold the object-relational mapping
  * metadata of the class with the given name.
  *
  * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service.
  *
  * @return void
  */
 public function initializeReflection($reflService)
 {
     $this->reflClass = $reflService->getClass($this->className);
     $this->className = $this->reflClass->getName();
     // normalize classname
 }
Example #6
0
 /**
  * Initializes a new ClassMetadata instance that will hold the object-relational mapping
  * metadata of the class with the given name.
  *
  * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service.
  *
  * @return void
  */
 public function initializeReflection($reflService)
 {
     $this->reflClass = $reflService->getClass($this->name);
     $this->namespace = $reflService->getClassNamespace($this->name);
     if ($this->reflClass) {
         $this->name = $this->rootDocumentName = $this->reflClass->getName();
     }
 }
 /**
  * @param ReflectionProperty $property
  *
  * @return null|ReflectionProperty
  */
 private function getAccessibleProperty(ReflectionProperty $property)
 {
     return $this->reflectionService->getAccessibleProperty($property->getDeclaringClass()->getName(), $property->getName());
 }
 protected function resurrect(\ReflectionProperty $property, ReflectionService $reflectionService)
 {
     return $reflectionService->getAccessibleProperty($property->class, $property->name);
 }
 /**
  * Initializes a new ClassMetadata instance that will hold the object-relational mapping
  * metadata of the class with the given name.
  *
  * @param \Doctrine\Common\Persistence\Mapping\ReflectionService $reflService The reflection service.
  */
 public function initializeReflection($reflService)
 {
     $this->reflClass = $reflService->getClass($this->name);
     $this->namespace = $reflService->getClassNamespace($this->name);
     $this->xmlName = Inflector::xmlize($this->reflClass->getShortName());
     if ($this->reflClass) {
         $this->name = $this->rootXmlEntityName = $this->reflClass->getName();
     }
 }
Example #10
0
 /**
  * Initializes a new ClassMetadata instance that will hold the
  * object-relational mapping metadata of the class with the given name.
  *
  * @param ReflectionService $reflService
  */
 public function initializeReflection(ReflectionService $reflService)
 {
     $this->reflClass = $reflService->getClass($this->name);
     $this->namespace = $reflService->getClassNamespace($this->name);
 }
Example #11
0
 /**
  * Restores some state that can not be serialized/unserialized.
  *
  * @param ReflectionService $reflService
  *
  * @return void
  */
 public function wakeupReflection($reflService)
 {
     // Restore ReflectionClass and properties
     $this->reflClass = $reflService->getClass($this->name);
     foreach ($this->fieldMappings as $field => $mapping) {
         $this->reflFields[$field] = $reflService->getAccessibleProperty($this->name, $field);
     }
 }
Example #12
0
 /**
  * Restores some state that can not be serialized/unserialized.
  *
  * @param ReflectionService $reflService
  */
 public function wakeupReflection(ReflectionService $reflService)
 {
     $this->reflClass = $reflService->getClass($this->name);
     $this->namespace = $reflService->getClassNamespace($this->name);
     foreach ($this->fieldMappings as $field => $mapping) {
         if (isset($mapping['declared'])) {
             $reflField = new ReflectionProperty($mapping['declared'], $field);
         } else {
             $reflField = $this->reflClass->getProperty($field);
         }
         $reflField->setAccessible(true);
         $this->reflFields[$field] = $reflField;
     }
     foreach ($this->fieldMappings as $field => $mapping) {
         if (isset($mapping['declared'])) {
             $reflField = new ReflectionProperty($mapping['declared'], $field);
         } else {
             $reflField = $this->reflClass->getProperty($field);
         }
         $reflField->setAccessible(true);
         $this->reflFields[$field] = $reflField;
     }
 }