From 5447b95c0a0d8d8759fffda350ecd87708cf3c9f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 29 Sep 2022 15:17:06 +0200 Subject: [PATCH] Show last import time beside each import configuration in backend module (#77) --- .../Model/Backend/ImportConfiguration.php | 22 +++++++++++++++++++ .../TCA/tx_thuecat_import_configuration.php | 9 ++++++++ Documentation/Changelog/1.3.0.rst | 10 +++++---- Resources/Private/Language/locallang.xlf | 6 +++++ .../Templates/Backend/Overview/Index.html | 11 ++++++++++ ext_tables.sql | 1 + 6 files changed, 55 insertions(+), 4 deletions(-) diff --git a/Classes/Domain/Model/Backend/ImportConfiguration.php b/Classes/Domain/Model/Backend/ImportConfiguration.php index 3fcc810..270cedc 100644 --- a/Classes/Domain/Model/Backend/ImportConfiguration.php +++ b/Classes/Domain/Model/Backend/ImportConfiguration.php @@ -26,6 +26,7 @@ namespace WerkraumMedia\ThueCat\Domain\Model\Backend; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\DomainObject\AbstractEntity; +use TYPO3\CMS\Extbase\Persistence\ObjectStorage; use WerkraumMedia\ThueCat\Domain\Import\Entity\Properties\ForeignReference; use WerkraumMedia\ThueCat\Domain\Import\ImportConfiguration as ImportConfigurationInterface; use WerkraumMedia\ThueCat\Domain\Import\ResolveForeignReference; @@ -52,6 +53,11 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI */ protected $tstamp = null; + /** + * @var ObjectStorage + */ + protected $logs; + /** * @var string[]|null */ @@ -62,6 +68,11 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI */ protected $allowedTypes = []; + public function __construct() + { + $this->logs = new ObjectStorage(); + } + public function getTitle(): string { return $this->title; @@ -82,6 +93,17 @@ class ImportConfiguration extends AbstractEntity implements ImportConfigurationI return $this->tstamp; } + public function getLastImported(): ?\DateTimeImmutable + { + $positionOfLastLog = count($this->logs) - 1; + $lastImport = $this->logs->offsetGet((string) $positionOfLastLog); + if (!$lastImport instanceof ImportLog) { + return null; + } + + return $lastImport->getCreated(); + } + public function getStoragePid(): int { if ($this->configuration === '') { diff --git a/Configuration/TCA/tx_thuecat_import_configuration.php b/Configuration/TCA/tx_thuecat_import_configuration.php index 05186b5..3867b78 100644 --- a/Configuration/TCA/tx_thuecat_import_configuration.php +++ b/Configuration/TCA/tx_thuecat_import_configuration.php @@ -68,6 +68,15 @@ return (static function (string $extensionKey, string $tableName) { 'readOnly' => true, ], ], + // Configured for usage within Extbase, not TCA itself + 'logs' => [ + 'config' => [ + 'type' => 'inline', + 'foreign_table' => 'tx_thuecat_import_log', + 'foreign_field' => 'configuration', + 'readOnly' => true, + ], + ], ], 'types' => [ '0' => [ diff --git a/Documentation/Changelog/1.3.0.rst b/Documentation/Changelog/1.3.0.rst index 5b3b5f8..c1b7831 100644 --- a/Documentation/Changelog/1.3.0.rst +++ b/Documentation/Changelog/1.3.0.rst @@ -9,7 +9,9 @@ Nothing Features -------- -Add support for TYPO3 v11 and PHP 8.0 + 8.1. +* Add support for TYPO3 v11 and PHP 8.0 + 8.1. + +* Last import date is now shown within backend module beside each import configuration. Fixes ----- @@ -34,9 +36,9 @@ Fixes Tasks ----- -Removed API Key from site configuration. -The key was already moved to extension configuration as documented. -Still we extended the site configuration, which is now cleaned up, see: https://github.com/werkraum-media/thuecat/issues/55 +* Removed API Key from site configuration. + The key was already moved to extension configuration as documented. + Still we extended the site configuration, which is now cleaned up, see: https://github.com/werkraum-media/thuecat/issues/55 Deprecation ----------- diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 2b98390..9775c60 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -46,6 +46,12 @@ Last changed + + Last imported + + + Never + create the first to get started.]]> diff --git a/Resources/Private/Templates/Backend/Overview/Index.html b/Resources/Private/Templates/Backend/Overview/Index.html index 2dd223e..e88e28e 100644 --- a/Resources/Private/Templates/Backend/Overview/Index.html +++ b/Resources/Private/Templates/Backend/Overview/Index.html @@ -55,6 +55,7 @@ {f:translate(id: 'module.importConfigurations.title')} {f:translate(id: 'module.importConfigurations.lastChanged')} + {f:translate(id: 'module.importConfigurations.lastImported')} {f:translate(id: 'module.actions')} @@ -63,6 +64,16 @@ {importConfiguration.title} {importConfiguration.lastChanged -> f:format.date(format: 'd.m.Y H:i')} + + + + {importConfiguration.lastImported -> f:format.date(format: 'd.m.Y H:i')} + + + {f:translate(id: 'module.importConfigurations.lastImported.never')} + + +