DCOM-93 - Add ClassMetadataFactory#wakeupReflection implementation
This commit is contained in:
parent
80408ac34f
commit
ea2d4e4282
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,4 +70,9 @@ class DisconnectedClassMetadataFactory extends ClassMetadataFactory
|
|||||||
{
|
{
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public function getReflectionService()
|
||||||
|
{
|
||||||
|
return new \Doctrine\Common\Persistence\Mapping\StaticReflectionService;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user