Skip to content

Commit 1fc2955

Browse files
committed
BUGFIX: reset empty object values in default language
1 parent a817f09 commit 1fc2955

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Classes/Sandstorm/GedmoTranslatableConnector/TranslatableTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,16 +194,16 @@ public function setTranslations(array $translations) {
194194
// $locale class property overwrites the translatable listener (for some reasons, this is not always the same)
195195
$locale = $this->locale ?? $this->translatableListener->getTranslatableLocale($this, $meta, $this->entityManager);
196196
foreach ($properties as $propertyName => $translatedValue) {
197+
if ($language === $locale) {
198+
ObjectAccess::setProperty($this, $propertyName, $translatedValue);
199+
}
197200
/* Do not store empty translations since gedmo extension's behaviour has changed in
198201
https://github.com/Atlantic18/DoctrineExtensions/commit/6cc9fb3864a2562806d8a66276196825e3181c49 */
199202
if ($translatedValue) {
200-
if ($language === $locale) {
203+
if ($language !== $locale) {
201204
/* Do not translate the default language by the repository. The repository->translate() does the
202205
same, but also persists the object ($this). However, persisting the object should not be handled
203-
withing this setter.
204-
TODO: Rethink the concept of calling the translation repository in here. Move it to a doctrine persistence listener? */
205-
ObjectAccess::setProperty($this, $propertyName, $translatedValue);
206-
} else {
206+
withing this setter. */
207207
$repository->translate($this, $propertyName, $language, $translatedValue);
208208
}
209209
} else {

0 commit comments

Comments
 (0)