mirror of
https://github.com/werkraum-media/thuecat.git
synced 2024-12-04 19:16:13 +01:00
Change flash message in case of error
Still very simple, but can be improved in future updates. E.g. add info regarding error, or deep link to single import log with errors, etc. To provide that, we need to add some more code, which is not necessary yet.
This commit is contained in:
parent
ba564f29f7
commit
2ddd52b284
3 changed files with 44 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
]),
|
||||
|
|
|
@ -97,6 +97,12 @@
|
|||
<trans-unit id="controller.backend.import.import.success.text" xml:space="preserve">
|
||||
<source>Imported configuration "%1$s".</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="controller.backend.import.import.error.title" xml:space="preserve">
|
||||
<source>Import finished</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="controller.backend.import.import.error.text" xml:space="preserve">
|
||||
<source>Imported configuration "%1$s". But had at least one error.</source>
|
||||
</trans-unit>
|
||||
</body>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Reference in a new issue