|
@@ -532,18 +532,23 @@ class TranslatableListener extends MappedEventSubscriber
|
|
if ($translation) {
|
|
if ($translation) {
|
|
// set the translated field, take value using reflection
|
|
// set the translated field, take value using reflection
|
|
$value = $wrapped->getPropertyValue($field);
|
|
$value = $wrapped->getPropertyValue($field);
|
|
- $translation->setContent($ea->getTranslationValue($object, $field));
|
|
|
|
- if ($isInsert && !$objectId && !$ea->usesPersonalTranslation($translationClass)) {
|
|
|
|
- // if we do not have the primary key yet available
|
|
|
|
- // keep this translation in memory to insert it later with foreign key
|
|
|
|
- $this->pendingTranslationInserts[spl_object_hash($object)][] = $translation;
|
|
|
|
- } else {
|
|
|
|
- // persist and compute change set for translation
|
|
|
|
- if ($wasPersistedSeparetely) {
|
|
|
|
- $ea->recomputeSingleObjectChangeset($uow, $translationMetadata, $translation);
|
|
|
|
- } else {
|
|
|
|
- $om->persist($translation);
|
|
|
|
- $uow->computeChangeSet($translationMetadata, $translation);
|
|
|
|
|
|
+ $content = $ea->getTranslationValue($object, $field);
|
|
|
|
+ $translation->setContent($content);
|
|
|
|
+ if (!empty($content)) {
|
|
|
|
+ if ($isInsert && !$objectId && !$ea->usesPersonalTranslation($translationClass)) {
|
|
|
|
+ // if we do not have the primary key yet available
|
|
|
|
+ // keep this translation in memory to insert it later with foreign key
|
|
|
|
+ $this->pendingTranslationInserts[spl_object_hash($object)][] = $translation;
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ // persist and compute change set for translation
|
|
|
|
+ if ($wasPersistedSeparetely) {
|
|
|
|
+ $ea->recomputeSingleObjectChangeset($uow, $translationMetadata, $translation);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $om->persist($translation);
|
|
|
|
+ $uow->computeChangeSet($translationMetadata, $translation);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -556,7 +561,8 @@ class TranslatableListener extends MappedEventSubscriber
|
|
foreach ($changeSet as $field => $changes) {
|
|
foreach ($changeSet as $field => $changes) {
|
|
if (in_array($field, $translatableFields)) {
|
|
if (in_array($field, $translatableFields)) {
|
|
if ($locale !== $this->defaultLocale) {
|
|
if ($locale !== $this->defaultLocale) {
|
|
- $wrapped->setPropertyValue($field, $changes[0]);
|
|
|
|
|
|
+ // Useless : don't change anything
|
|
|
|
+ //$wrapped->setPropertyValue($field, $changes[1]);
|
|
$ea->setOriginalObjectProperty($uow, $oid, $field, $changes[0]);
|
|
$ea->setOriginalObjectProperty($uow, $oid, $field, $changes[0]);
|
|
unset($modifiedChangeSet[$field]);
|
|
unset($modifiedChangeSet[$field]);
|
|
}
|
|
}
|