From 5b131344bb78b3700baa7e5fda1a53c91f86799e Mon Sep 17 00:00:00 2001 From: Ben Walch Date: Wed, 20 Nov 2024 11:37:27 +0100 Subject: [PATCH] allow null values for index fields --- src/Generator/IndexDocumentGenerator.php | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Generator/IndexDocumentGenerator.php b/src/Generator/IndexDocumentGenerator.php index d09a59f..43ba9ec 100644 --- a/src/Generator/IndexDocumentGenerator.php +++ b/src/Generator/IndexDocumentGenerator.php @@ -94,11 +94,6 @@ protected function populateIndexDocument( $dataTransformerOptions = $documentDefinitionOptions['data_transformer']; $transformedData = $this->dispatchResourceFieldTransformer($dataTransformerOptions, $resourceScaffolderName, $resourceContainer); - if ($transformedData === null) { - // no error: transformer is allowed to refuse data - continue; - } - $optionFieldContainer = new OptionFieldContainer($fieldName, $transformedData); $indexDocument->addOptionField($optionFieldContainer); } @@ -133,11 +128,6 @@ protected function processDocumentDataTransformerField( $transformedData = $this->dispatchResourceFieldTransformer($dataTransformerOptions, $resourceScaffolderName, $resourceContainer); - if ($transformedData === null) { - // no error: transformer is allowed to refuse data - return; - } - if ($fieldType === 'pre_process_definition') { $documentDefinition->setCurrentLevel($fieldDefinitionOptions['level']); @@ -202,6 +192,10 @@ protected function dispatchResourceFieldTransformer(array $options, string $disp sprintf('Error while transform field resource with service "%s": %s', $fieldTransformerName, $e->getMessage())); } + if ($transformedData === '') { + return null; + } + return $transformedData; } @@ -226,10 +220,6 @@ protected function dispatchIndexTransformer(ContextDefinitionInterface $contextD ); } - if ($indexFieldData === null) { - return null; - } - return $indexFieldData; }