Skip to content

Commit

Permalink
Moving code inside foreach.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwage committed Aug 7, 2010
1 parent 236d4c6 commit c45ba00
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/Doctrine/ODM/MongoDB/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,6 @@ public function computeChangeSet(Mapping\ClassMetadata $class, $document)
if ( ! $class->isIdentifier($name) || $class->getAllowCustomID()) {
$actualData[$name] = $class->getFieldValue($document, $mapping['fieldName']);
}

if ($class->isCollectionValuedReference($name) && $actualData[$name] !== null
&& ! ($actualData[$name] instanceof PersistentReferenceCollection)) {
// If $actualData[$name] is not a Collection then use an ArrayCollection.
Expand All @@ -387,20 +386,20 @@ public function computeChangeSet(Mapping\ClassMetadata $class, $document)
$class->reflFields[$name]->setValue($document, $coll);
$actualData[$name] = $coll;
}
}
if ($class->isCollectionValuedEmbed($name) && $actualData[$name] !== null
&& ! ($actualData[$name] instanceof Collection)) {
// If $actualData[$name] is not a Collection then use an ArrayCollection.
if ( ! $actualData[$name] instanceof Collection) {
$actualData[$name] = new ArrayCollection($actualData[$name]);
}
if ($class->isCollectionValuedEmbed($name) && $actualData[$name] !== null
&& ! ($actualData[$name] instanceof Collection)) {
// If $actualData[$name] is not a Collection then use an ArrayCollection.
if ( ! $actualData[$name] instanceof Collection) {
$actualData[$name] = new ArrayCollection($actualData[$name]);
}

// Inject PersistentEmbeddedCollection
$coll = new PersistentEmbeddedCollection($actualData[$name]);
$coll->setOwner($document, $mapping);
$coll->setDirty( ! $coll->isEmpty());
$class->reflFields[$name]->setValue($document, $coll);
$actualData[$name] = $coll;
// Inject PersistentEmbeddedCollection
$coll = new PersistentEmbeddedCollection($actualData[$name]);
$coll->setOwner($document, $mapping);
$coll->setDirty( ! $coll->isEmpty());
$class->reflFields[$name]->setValue($document, $coll);
$actualData[$name] = $coll;
}
}

if ( ! isset($this->_originalDocumentData[$oid])) {
Expand Down

0 comments on commit c45ba00

Please sign in to comment.