Skip to content

Commit 4553685

Browse files
authored
Merge pull request #10 from swisscomeventandmedia/task/swisscomeventandmedia-sync
swisscomeventandmedia sync
2 parents 361bc07 + 8e29227 commit 4553685

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Classes/Sandstorm/GedmoTranslatableConnector/TranslatableTrait.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,14 @@ public function setTranslations(array $translations) {
190190
$repository = $this->entityManager->getRepository('Gedmo\\Translatable\\Entity\\Translation');
191191

192192
foreach ($translations as $language => $properties) {
193-
foreach ($properties as $propertyName => $translatedValue) {
193+
$meta = $this->entityManager->getClassMetadata(get_class($this));
194+
// $locale class property overwrites the translatable listener (for some reasons, this is not always the same)
195+
$locale = $this->locale ?? $this->translatableListener->getTranslatableLocale($this, $meta, $this->entityManager);
196+
foreach ($properties as $propertyName => $translatedValue) {
194197
/* Do not store empty translations since gedmo extension's behaviour has changed in
195198
https://github.com/Atlantic18/DoctrineExtensions/commit/6cc9fb3864a2562806d8a66276196825e3181c49 */
196199
if ($translatedValue) {
197-
$meta = $this->entityManager->getClassMetadata(get_class($this));
198-
if ($language === $this->translatableListener->getTranslatableLocale($this, $meta, $this->entityManager)) {
200+
if ($language === $locale) {
199201
/* Do not translate the default language by the repository. The repository->translate() does the
200202
same, but also persists the object ($this). However, persisting the object should not be handled
201203
withing this setter.

Configuration/Settings.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ Sandstorm:
88
Neos:
99
Flow:
1010
object:
11-
excludeClasses:
11+
includeClasses:
1212
gedmo.doctrineextensions:
13-
- 'Gedmo\\.*'
13+
- 'Gedmo\\Translatable\\Entity'
1414
persistence:
1515
doctrine:
1616
eventListeners:

0 commit comments

Comments
 (0)