Skip to content

Commit

Permalink
Quick fix for #7127
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpustulka committed Jul 29, 2015
1 parent c927def commit 0fe7060
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/ORM/Behavior/TranslateBehavior.php
Expand Up @@ -439,24 +439,26 @@ protected function _rowMapper($results, $locale)
public function groupTranslations($results)
{
return $results->map(function ($row) {
$translations = (array)$row->get('_i18n');
$grouped = new Collection($translations);

$result = [];
foreach ($grouped->combine('field', 'content', 'locale') as $locale => $keys) {
$entityClass = $this->_table->entityClass();
$translation = new $entityClass($keys + ['locale' => $locale], [
'markNew' => false,
'useSetters' => false,
'markClean' => true
]);
$result[$locale] = $translation;
}
if ($row instanceof EntityInterface) {
$translations = (array)$row->get('_i18n');
$grouped = new Collection($translations);

$result = [];
foreach ($grouped->combine('field', 'content', 'locale') as $locale => $keys) {
$entityClass = $this->_table->entityClass();
$translation = new $entityClass($keys + ['locale' => $locale], [
'markNew' => false,
'useSetters' => false,
'markClean' => true
]);
$result[$locale] = $translation;
}

$options = ['setter' => false, 'guard' => false];
$row->set('_translations', $result, $options);
unset($row['_i18n']);
$row->clean();
$options = ['setter' => false, 'guard' => false];
$row->set('_translations', $result, $options);
unset($row['_i18n']);
$row->clean();
}
return $row;
});
}
Expand Down

0 comments on commit 0fe7060

Please sign in to comment.