From 094c2a2fe536636310a8e6717029db139ce07619 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Sat, 4 Mar 2017 22:04:27 +0100 Subject: [PATCH] Improve empty property check --- src/ORM/Behavior/TranslateBehavior.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/ORM/Behavior/TranslateBehavior.php b/src/ORM/Behavior/TranslateBehavior.php index 4cafc3627a1..7cad326cf4e 100644 --- a/src/ORM/Behavior/TranslateBehavior.php +++ b/src/ORM/Behavior/TranslateBehavior.php @@ -658,12 +658,11 @@ protected function _unsetEmptyFields(EntityInterface $entity) } } - // Workaround to check the remaining properties - $arrayEntity = $entity->toArray(); + $translation = $translation->extract($this->_config['fields']); // If now, the current locale property is empty, // unset it completely. - if (empty($arrayEntity['_translations'][$locale])) { + if (empty(array_filter($translation))) { unset($entity->get('_translations')[$locale]); } }