From 1aeff68c0f40ee7e75b98531c0617bdf56dc5f35 Mon Sep 17 00:00:00 2001 From: jwage Date: Fri, 10 Jul 2009 21:47:42 +0000 Subject: [PATCH] [2.0] Initial commit to make hydration work with C extension --- lib/Doctrine/ORM/Configuration.php | 13 ++++++++++++- lib/Doctrine/ORM/UnitOfWork.php | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 3a22ddf36..ebc55c316 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -47,7 +47,8 @@ class Configuration extends \Doctrine\DBAL\Configuration 'metadataDriverImpl' => new AnnotationDriver(), 'dqlClassAliasMap' => array(), 'cacheDir' => null, - 'allowPartialObjects' => true + 'allowPartialObjects' => true, + 'useCExtension' => false )); } @@ -186,4 +187,14 @@ class Configuration extends \Doctrine\DBAL\Configuration { $this->_attributes['metadataCacheImpl'] = $cacheImpl; } + + public function getUseCExtension() + { + return $this->_attributes['useCExtension']; + } + + public function setUseCExtension($boolean) + { + $this->_attributes['useCExtension'] = $boolean; + } } \ No newline at end of file diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 6d8a73dac..180f06960 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -204,6 +204,13 @@ class UnitOfWork implements PropertyChangedListener */ private $_collectionPersisters = array(); + /** + * Flag for whether or not to use the C extension for hydration + * + * @var string + */ + private $_useCExtension = false; + /** * Initializes a new UnitOfWork instance, bound to the given EntityManager. * @@ -214,6 +221,7 @@ class UnitOfWork implements PropertyChangedListener $this->_em = $em; //TODO: any benefit with lazy init? $this->_commitOrderCalculator = new CommitOrderCalculator(); + $this->_useCExtension = $this->_em->getConfiguration()->getUseCExtension(); } /** @@ -1334,9 +1342,13 @@ class UnitOfWork implements PropertyChangedListener } if ($overrideLocalChanges) { - foreach ($data as $field => $value) { - if (isset($class->reflFields[$field])) { - $class->reflFields[$field]->setValue($entity, $value); + if ($this->_useCExtension) { + doctrine_populate_data($entity, $data); + } else { + foreach ($data as $field => $value) { + if (isset($class->reflFields[$field])) { + $class->reflFields[$field]->setValue($entity, $value); + } } } } else {