Skip to content

Commit

Permalink
More marshaller tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jul 10, 2014
1 parent eaa62ee commit 4bf5f10
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/ORM/Marshaller.php
Expand Up @@ -256,7 +256,7 @@ public function merge(EntityInterface $entity, array $data, array $options = [])

if (isset($propertyMap[$key])) {
$assoc = $propertyMap[$key]['association'];
$nested = $propertyMap[$key]['nested'];
$nested = ['associated' => $propertyMap[$key]['nested']];
$value = $this->_mergeAssociation($original, $assoc, $value, $nested);
} elseif ($columnType) {
$converter = Type::build($columnType);
Expand Down Expand Up @@ -363,14 +363,15 @@ protected function _mergeAssociation($original, $assoc, $value, $options) {
*/
protected function _mergeBelongsToMany($original, $assoc, $value, $options) {
$hasIds = array_key_exists('_ids', $value);
$associated = isset($options['associated']) ? $options['associated'] : [];
if ($hasIds && is_array($value['_ids'])) {
return $this->_loadBelongsToMany($assoc, $value['_ids']);
}
if ($hasIds) {
return [];
}

if (!in_array('_joinData', $options) && !isset($options['_joinData'])) {
if (!in_array('_joinData', $associated) && !isset($associated['_joinData'])) {
return $this->mergeMany($original, $value, $options);
}

Expand All @@ -386,8 +387,8 @@ protected function _mergeBelongsToMany($original, $assoc, $value, $options) {
$marshaller = $joint->marshaller();

$nested = [];
if (isset($options['_joinData']['associated'])) {
$nested = (array)$options['_joinData']['associated'];
if (isset($associated['_joinData']['associated'])) {
$nested = ['associated' => (array)$associated['_joinData']['associated']];
}

$records = $this->mergeMany($original, $value, $options);
Expand Down

0 comments on commit 4bf5f10

Please sign in to comment.