From 1873d3bb1329cbd49c29a6678d3657f3261566b6 Mon Sep 17 00:00:00 2001 From: Mathias Brodala Date: Tue, 15 Oct 2024 16:49:00 +0200 Subject: [PATCH] [TASK] Add data transform warning messages These are especially helpful when using the import by Reaction to give the caller hints about possible errors. --- Classes/Step/TransformDataStep.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Classes/Step/TransformDataStep.php b/Classes/Step/TransformDataStep.php index e646b39..cc09cb2 100644 --- a/Classes/Step/TransformDataStep.php +++ b/Classes/Step/TransformDataStep.php @@ -23,6 +23,7 @@ use Cobweb\ExternalImport\ImporterAwareInterface; use Cobweb\ExternalImport\Utility\MappingUtility; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; +use TYPO3\CMS\Core\Messaging\AbstractMessage; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; @@ -252,6 +253,11 @@ public function applyUserFunction(string $name, array $configuration, array $rec } catch (InvalidRecordException $e) { // This exception means that the record must be removed from the dataset entirely unset($records[$index]); + + $this->importer->addMessage( + $e->getMessage(), + AbstractMessage::WARNING + ); $this->importer->debug( LocalizationUtility::translate( 'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:invalidRecordRemoved', @@ -270,6 +276,11 @@ public function applyUserFunction(string $name, array $configuration, array $rec } catch (\Exception $e) { // If the value could not be transformed, remove it from the imported dataset unset($records[$index][$name]); + + $this->importer->addMessage( + $e->getMessage(), + AbstractMessage::WARNING + ); $this->importer->debug( LocalizationUtility::translate( 'LLL:EXT:external_import/Resources/Private/Language/ExternalImport.xlf:transformationFailedWithMessage',