[2.0] Initial commit to make hydration work with C extension
This commit is contained in:
parent
ba8b4337bb
commit
1aeff68c0f
@ -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;
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user