From efb6c2427c865bf61bb62676c39e46559f78a12f Mon Sep 17 00:00:00 2001 From: Giulia Pellegrini Date: Fri, 27 Oct 2017 09:22:38 +0200 Subject: [PATCH] [Translatable] Do not persist new translations if empty Do not persist new translations if empty --- src/Model/Translatable/TranslatableMethods.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Model/Translatable/TranslatableMethods.php b/src/Model/Translatable/TranslatableMethods.php index dc32363d..f4869fa1 100644 --- a/src/Model/Translatable/TranslatableMethods.php +++ b/src/Model/Translatable/TranslatableMethods.php @@ -130,7 +130,7 @@ protected function doTranslate($locale = null, $fallbackToDefault = true) public function mergeNewTranslations() { foreach ($this->getNewTranslations() as $newTranslation) { - if (!$this->getTranslations()->contains($newTranslation)) { + if (!$this->getTranslations()->contains($newTranslation) && !$newTranslation->isEmpty()) { $this->addTranslation($newTranslation); $this->getNewTranslations()->removeElement($newTranslation); } @@ -171,10 +171,10 @@ public function getDefaultLocale() /** * An extra feature allows you to proxy translated fields of a translatable entity. - * + * * @param string $method * @param array $arguments - * + * * @return mixed The translated value of the field for current locale */ protected function proxyCurrentLocaleTranslation($method, array $arguments = [])