1
0
mirror of synced 2025-01-18 14:31:40 +03:00

DCOM-93 - Add ClassMetadataFactory#wakeupReflection implementation

This commit is contained in:
Benjamin Eberlei 2012-01-02 15:46:20 +01:00
parent 80408ac34f
commit ea2d4e4282
2 changed files with 23 additions and 1 deletions

View File

@ -172,6 +172,7 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
if ($this->cacheDriver) { if ($this->cacheDriver) {
if (($cached = $this->cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) { if (($cached = $this->cacheDriver->fetch("$realClassName\$CLASSMETADATA")) !== false) {
$this->wakeupReflection($cached, $this->getReflectionService());
$this->loadedMetadata[$realClassName] = $cached; $this->loadedMetadata[$realClassName] = $cached;
} else { } else {
foreach ($this->loadMetadata($realClassName) as $loadedClassName) { foreach ($this->loadMetadata($realClassName) as $loadedClassName) {
@ -575,6 +576,22 @@ class ClassMetadataFactory implements ClassMetadataFactoryInterface
*/ */
protected function wakeupReflection(ClassMetadataInfo $class, ReflectionService $reflService) protected function wakeupReflection(ClassMetadataInfo $class, ReflectionService $reflService)
{ {
// Restore ReflectionClass and properties
$class->reflClass = $reflService->getClass($class->name);
foreach ($class->fieldMappings as $field => $mapping) {
$reflField = isset($mapping['declared'])
? $reflService->getAccessibleProperty($mapping['declared'], $field)
: $reflService->getAccessibleProperty($class->name, $field);
$class->reflFields[$field] = $reflField;
}
foreach ($class->associationMappings as $field => $mapping) {
$reflField = isset($mapping['declared'])
? $reflService->getAccessibleProperty($mapping['declared'], $field)
: $reflService->getAccessibleProperty($class->name, $field);
$class->reflFields[$field] = $reflField;
}
} }
/** /**

View File

@ -70,4 +70,9 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
{ {
return array(); return array();
} }
public function getReflectionService()
{
return new \Doctrine\Common\Persistence\Mapping\StaticReflectionService;
}
} }