From ac1f466c70d452d8dd932ae20637168208cc9289 Mon Sep 17 00:00:00 2001 From: Bob den Otter Date: Fri, 4 Jan 2019 09:54:54 +0100 Subject: [PATCH] Don't break when missing translation encountered --- .gitignore | 1 + src/EventListener/StorageListener.php | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index ba9fa4a..44e0f09 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock vendor/ tests/tmp/ .couscous +.idea/ diff --git a/src/EventListener/StorageListener.php b/src/EventListener/StorageListener.php index efe7e4e..e9cdc4b 100644 --- a/src/EventListener/StorageListener.php +++ b/src/EventListener/StorageListener.php @@ -136,7 +136,13 @@ public function postHydrate(HydrationEvent $event) if (!isset($subject[$localeSlug . 'data'])) { return; } + $localeData = json_decode($subject[$localeSlug . 'data'], true); + + if (empty($localeData)) { + return; + } + foreach ($localeData as $key => $value) { if ($key === 'templatefields' && !($subject['template'] === null && !isset($contentType['record_template']))) { if (isset($subject['template']) && $subject['template'] === null) {