From 207358f0a0ceb35dfa294a98dd4f82d92bad15d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Wolda=C5=84ski?= Date: Thu, 11 Jul 2024 16:05:09 +0200 Subject: [PATCH] [FEATURE] Add `nullableFieldsIfEmpty` option to JsonContentObject This new option adds ability to define which fields should be set to null when parsed TypoScript returns empty string --- Classes/ContentObject/JsonContentObject.php | 3 ++- Tests/Unit/ContentObject/JsonContentObjectTest.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Classes/ContentObject/JsonContentObject.php b/Classes/ContentObject/JsonContentObject.php index 997b1aca..7a220e9d 100755 --- a/Classes/ContentObject/JsonContentObject.php +++ b/Classes/ContentObject/JsonContentObject.php @@ -97,6 +97,7 @@ public function render($conf = []): string public function cObjGet(array $setup, string $addKey = ''): array { $content = []; + $nullableFieldsOnEmpty = GeneralUtility::trimExplode(',', $this->conf['nullableFieldsIfEmpty'] ?? '', true); $sKeyArray = $this->filterByStringKeys($setup); foreach ($sKeyArray as $theKey) { @@ -117,7 +118,7 @@ public function cObjGet(array $setup, string $addKey = ''): array if ($theValue === 'USER_INT' || str_starts_with((string)$content[$theKey], '