diff --git a/Classes/Controller/Backend/ImportController.php b/Classes/Controller/Backend/ImportController.php index 7a849b3..d8766a8 100644 --- a/Classes/Controller/Backend/ImportController.php +++ b/Classes/Controller/Backend/ImportController.php @@ -23,6 +23,7 @@ namespace WerkraumMedia\ThueCat\Controller\Backend; * 02110-1301, USA. */ +use TYPO3\CMS\Core\Messaging\AbstractMessage; use WerkraumMedia\ThueCat\Domain\Import\Importer; use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration; use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportLogRepository; @@ -58,7 +59,40 @@ class ImportController extends AbstractController public function importAction(ImportConfiguration $importConfiguration): void { - $this->importer->importConfiguration($importConfiguration); + $importLog = $this->importer->importConfiguration($importConfiguration); + + if ($importLog->hasErrors()) { + $this->createImportErrorFlashMessage($importConfiguration); + } else { + $this->createImportDoneFlashMessage($importConfiguration); + } + + $this->redirect('index', 'Backend\Overview'); + } + + protected function getMenu(): Menu + { + return $this->menu; + } + + private function createImportErrorFlashMessage(ImportConfiguration $importConfiguration): void + { + $this->addFlashMessage( + $this->translation->translate( + 'controller.backend.import.import.error.text', + Extension::EXTENSION_NAME, + [$importConfiguration->getTitle()] + ), + $this->translation->translate( + 'controller.backend.import.import.error.title', + Extension::EXTENSION_NAME + ), + AbstractMessage::ERROR + ); + } + + private function createImportDoneFlashMessage(ImportConfiguration $importConfiguration): void + { $this->addFlashMessage( $this->translation->translate( 'controller.backend.import.import.success.text', @@ -68,13 +102,8 @@ class ImportController extends AbstractController $this->translation->translate( 'controller.backend.import.import.success.title', Extension::EXTENSION_NAME - ) + ), + AbstractMessage::OK ); - $this->redirect('index', 'Backend\Overview'); - } - - protected function getMenu(): Menu - { - return $this->menu; } } diff --git a/Classes/Domain/Import/Importer/SaveData.php b/Classes/Domain/Import/Importer/SaveData.php index b714dcc..a727afb 100644 --- a/Classes/Domain/Import/Importer/SaveData.php +++ b/Classes/Domain/Import/Importer/SaveData.php @@ -49,7 +49,7 @@ class SaveData $identifier = $this->getIdentifier($entity); $dataHandler->start([ $entity->getTypo3DatabaseTableName() => [ - $identifier => array_merge($entity->getData(), [ + $identifier => array_merge($entity->getData(), [ 'pid' => $entity->getTypo3StoragePid(), 'remote_id' => $entity->getRemoteId(), ]), diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index ad9e211..6b2e759 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -97,6 +97,12 @@ Imported configuration "%1$s". + + Import finished + + + Imported configuration "%1$s". But had at least one error. +