From b29d47a682b300a274b26fdf8a33ddf91216ac31 Mon Sep 17 00:00:00 2001 From: "Fabio B. Silva" Date: Sat, 21 Jan 2012 18:16:38 -0200 Subject: [PATCH] cache new object mappings --- .../ORM/Internal/Hydration/AbstractHydrator.php | 12 +++++++----- .../ORM/Internal/Hydration/ObjectHydrator.php | 5 ++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php index f8eb6b820..8631dc297 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php @@ -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'])) { diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index 7275ffa76..7ab624ec0 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -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); } }