1
0
mirror of synced 2025-01-17 22:11:41 +03:00

cache new object mappings

This commit is contained in:
Fabio B. Silva 2012-01-21 18:16:38 -02:00
parent 0fbb78e61a
commit b29d47a682
2 changed files with 9 additions and 8 deletions

View File

@ -237,15 +237,17 @@ abstract class AbstractHydrator
if (isset ($this->_rsm->newObjectMappings[$key])) {
$cache[$key]['isNewObjectParameter'] = true;
$cache[$key]['argIndex'] = $this->_rsm->newObjectMappings[$key]['argIndex'];
$cache[$key]['objIndex'] = $this->_rsm->newObjectMappings[$key]['objIndex'];
$cache[$key]['class'] = new \ReflectionClass($this->_rsm->newObjectMappings[$key]['className']);
}
}
if (isset ($cache[$key]['isNewObjectParameter'])) {
$argIndex = $this->_rsm->newObjectMappings[$key]['argIndex'];
$objIndex = $this->_rsm->newObjectMappings[$key]['objIndex'];
$className = $this->_rsm->newObjectMappings[$key]['className'];
$rowData['newObjects'][$objIndex]['className'] = $className;
$rowData['newObjects'][$objIndex]['args'][$argIndex] = $cache[$key]['fieldName'];
$argIndex = $cache[$key]['argIndex'];
$objIndex = $cache[$key]['objIndex'];
$rowData['newObjects'][$objIndex]['class'] = $cache[$key]['class'];
$rowData['newObjects'][$objIndex]['args'][$argIndex] = $cache[$key]['fieldName'];
}
if (isset($cache[$key]['isScalar'])) {

View File

@ -550,12 +550,11 @@ class ObjectHydrator extends AbstractHydrator
}
foreach ($newObjects as $newObject) {
$args = array();
$className = $newObject['className'];
$args = array();
$class = $newObject['class'];
foreach ($newObject['args'] as $index => $name) {
$args[$index] = $result[$resultKey][$name];
}
$class = new \ReflectionClass($className);
$result[$resultKey] = $class->newInstanceArgs($args);
}
}