Skip to content
Permalink
Browse files

More marshaller tests fixed

  • Loading branch information...
lorenzo committed Jul 10, 2014
1 parent eaa62ee commit 4bf5f107cbe57378f703681733835879a4c3ee32
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/ORM/Marshaller.php
@@ -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);
@@ -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);
}
@@ -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);

0 comments on commit 4bf5f10

Please sign in to comment.
You can’t perform that action at this time.