diff --git a/typo3/sysext/backend/Classes/Backend/Event/SystemInformationToolbarCollectorEvent.php b/typo3/sysext/backend/Classes/Backend/Event/SystemInformationToolbarCollectorEvent.php new file mode 100644 index 0000000000000000000000000000000000000000..5cab9ef3b511bd0125edf1c20a87a7adcb121e11 --- /dev/null +++ b/typo3/sysext/backend/Classes/Backend/Event/SystemInformationToolbarCollectorEvent.php @@ -0,0 +1,40 @@ +<?php +declare(strict_types = 1); +namespace TYPO3\CMS\Backend\Backend\Event; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; + +/** + * An event to enrich the system information toolbar in the TYPO3 Backend top toolbar + * with various information + */ +final class SystemInformationToolbarCollectorEvent +{ + /** + * @var SystemInformationToolbarItem + */ + private $toolbarItem; + + public function __construct(SystemInformationToolbarItem $toolbarItem) + { + $this->toolbarItem = $toolbarItem; + } + + public function getToolbarItem(): SystemInformationToolbarItem + { + return $this->toolbarItem; + } +} diff --git a/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php b/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php index e62bd4b55176163e04248da410cddfa1286b81bc..d1895a7ef2f5d298a91a1e7adb4040b958d4d551 100644 --- a/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php +++ b/typo3/sysext/backend/Classes/Backend/ToolbarItems/SystemInformationToolbarItem.php @@ -14,6 +14,8 @@ namespace TYPO3\CMS\Backend\Backend\ToolbarItems; * The TYPO3 project - inspiring people to share! */ +use Psr\EventDispatcher\EventDispatcherInterface; +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus; use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface; @@ -27,8 +29,6 @@ use TYPO3\CMS\Core\Utility\CommandUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Core\Utility\VersionNumberUtility; -use TYPO3\CMS\Extbase\Object\ObjectManager; -use TYPO3\CMS\Extbase\SignalSlot\Dispatcher; use TYPO3\CMS\Fluid\View\StandaloneView; /** @@ -68,20 +68,18 @@ class SystemInformationToolbarItem implements ToolbarItemInterface protected $systemMessages = []; /** - * @var Dispatcher + * @var EventDispatcherInterface */ - protected $signalSlotDispatcher; + protected $eventDispatcher; /** * @var int */ protected $maximumCountInBadge = 99; - /** - * Constructor - */ - public function __construct() + public function __construct(EventDispatcherInterface $eventDispatcher = null) { + $this->eventDispatcher = $eventDispatcher ?? GeneralUtility::getContainer()->get(EventDispatcherInterface::class); $this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/SystemInformationMenu'); $this->highestSeverity = InformationStatus::cast(InformationStatus::STATUS_INFO); } @@ -231,8 +229,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface $this->getGitRevision(); $this->getOperatingSystem(); - $this->emitGetSystemInformation(); - $this->emitLoadMessages(); + $this->eventDispatcher->dispatch(new SystemInformationToolbarCollectorEvent($this)); $this->severityBadgeClass = !$this->highestSeverity->equals(InformationStatus::STATUS_NOTICE) ? 'badge-' . (string)$this->highestSeverity : ''; } @@ -371,22 +368,6 @@ class SystemInformationToolbarItem implements ToolbarItemInterface ]; } - /** - * Emits the "getSystemInformation" signal - */ - protected function emitGetSystemInformation() - { - $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'getSystemInformation', [$this]); - } - - /** - * Emits the "loadMessages" signal - */ - protected function emitLoadMessages() - { - $this->getSignalSlotDispatcher()->dispatch(__CLASS__, 'loadMessages', [$this]); - } - /** * Returns a new standalone view, shorthand function * @@ -433,17 +414,4 @@ class SystemInformationToolbarItem implements ToolbarItemInterface { return GeneralUtility::makeInstance(PageRenderer::class); } - - /** - * Get the SignalSlot dispatcher - * - * @return Dispatcher - */ - protected function getSignalSlotDispatcher() - { - if (!isset($this->signalSlotDispatcher)) { - $this->signalSlotDispatcher = GeneralUtility::makeInstance(ObjectManager::class)->get(Dispatcher::class); - } - return $this->signalSlotDispatcher; - } } diff --git a/typo3/sysext/backend/Classes/Compatibility/SlotReplacement.php b/typo3/sysext/backend/Classes/Compatibility/SlotReplacement.php new file mode 100644 index 0000000000000000000000000000000000000000..a0df516f0eb3ce77e76672845c9cd00a434e39b8 --- /dev/null +++ b/typo3/sysext/backend/Classes/Compatibility/SlotReplacement.php @@ -0,0 +1,54 @@ +<?php +declare(strict_types = 1); +namespace TYPO3\CMS\Backend\Compatibility; + +/* + * This file is part of the TYPO3 CMS project. + * + * It is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, either version 2 + * of the License, or any later version. + * + * For the full copyright and license information, please read the + * LICENSE.txt file that was distributed with this source code. + * + * The TYPO3 project - inspiring people to share! + */ + +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; +use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; +use TYPO3\CMS\Extbase\SignalSlot\Dispatcher as SignalSlotDispatcher; + +/** + * This class provides a replacement for all existing signals in EXT:backend of TYPO3 Core, which now act as a + * simple wrapper for PSR-14 events with a simple ("first prioritized") listener implementation. + * + * @internal Please note that this class will likely be removed in TYPO3 v11, and Extension Authors should + * switch to PSR-14 event listeners. + */ +class SlotReplacement +{ + /** + * @var SignalSlotDispatcher + */ + protected $signalSlotDispatcher; + + public function __construct(SignalSlotDispatcher $signalSlotDispatcher) + { + $this->signalSlotDispatcher = $signalSlotDispatcher; + } + + public function onSystemInformationToolbarEvent(SystemInformationToolbarCollectorEvent $event): void + { + $this->signalSlotDispatcher->dispatch( + SystemInformationToolbarItem::class, + 'getSystemInformation', + [$event->getToolbarItem()] + ); + $this->signalSlotDispatcher->dispatch( + SystemInformationToolbarItem::class, + 'loadMessages', + [$event->getToolbarItem()] + ); + } +} diff --git a/typo3/sysext/backend/Configuration/Services.yaml b/typo3/sysext/backend/Configuration/Services.yaml index c8814cea882e40d566b30f38dedbd56cc45403e2..d121c9d0c3790b2e27c33bd0f9ad4f2bea7cadfe 100644 --- a/typo3/sysext/backend/Configuration/Services.yaml +++ b/typo3/sysext/backend/Configuration/Services.yaml @@ -19,6 +19,13 @@ services: TYPO3\CMS\Backend\History\RecordHistoryRollback: public: true + # Listener for old Signal Slots + TYPO3\CMS\Backend\Compatibility\SlotReplacement: + tags: + - name: event.listener + identifier: 'legacy-slot' + method: 'onSystemInformationToolbarEvent' + event: TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent # Category security checks for backend users TYPO3\CMS\Backend\Security\CategoryPermissionsAspect: diff --git a/typo3/sysext/belog/Classes/Controller/SystemInformationController.php b/typo3/sysext/belog/Classes/Controller/SystemInformationController.php index 031580a70290275d3ed9256e14e7484bfddeced4..3d92ac0e2575ed3f985850a61910711ad719847e 100644 --- a/typo3/sysext/belog/Classes/Controller/SystemInformationController.php +++ b/typo3/sysext/belog/Classes/Controller/SystemInformationController.php @@ -15,7 +15,7 @@ namespace TYPO3\CMS\Belog\Controller; * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus; use TYPO3\CMS\Core\Database\Connection; @@ -24,10 +24,11 @@ use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; /** - * Count newest exceptions for the system information menu + * Count latest exceptions for the system information menu. + * * @internal This class is a TYPO3 Backend implementation and is not considered part of the Public TYPO3 API. */ -class SystemInformationController +final class SystemInformationController { /** * @var array @@ -40,12 +41,13 @@ class SystemInformationController } /** - * Modifies the SystemInformation array - * - * @param SystemInformationToolbarItem $systemInformationToolbarItem + * Modifies the SystemInformation toolbar to inject a new message + * @param SystemInformationToolbarCollectorEvent $event + * @throws \TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException */ - public function appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem) + public function appendMessage(SystemInformationToolbarCollectorEvent $event): void { + $systemInformationToolbarItem = $event->getToolbarItem(); // we can't use the extbase repository here as the required TypoScript may not be parsed yet $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('sys_log'); $count = $queryBuilder->count('error') @@ -82,7 +84,7 @@ class SystemInformationController } } - protected function fetchLastAccessTimestamp(): int + private function fetchLastAccessTimestamp(): int { if (!isset($this->backendUserConfiguration['systeminformation'])) { return 0; diff --git a/typo3/sysext/belog/Configuration/Services.yaml b/typo3/sysext/belog/Configuration/Services.yaml index 3dea960b038e9dc26edb557d8df61fbf25389bd6..7b8163cd054fd169040e8b7d6adea36a1835206f 100644 --- a/typo3/sysext/belog/Configuration/Services.yaml +++ b/typo3/sysext/belog/Configuration/Services.yaml @@ -6,3 +6,10 @@ services: TYPO3\CMS\Belog\: resource: '../Classes/*' + + TYPO3\CMS\Belog\Controller\SystemInformationController: + tags: + - name: event.listener + identifier: 'belog/show-latest-errors' + method: 'appendMessage' + event: TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent diff --git a/typo3/sysext/belog/ext_localconf.php b/typo3/sysext/belog/ext_localconf.php deleted file mode 100644 index 8040bedc86bebdc1c8189254fb602e4465f83d2e..0000000000000000000000000000000000000000 --- a/typo3/sysext/belog/ext_localconf.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php -defined('TYPO3_MODE') or die(); - -\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class) - ->connect( - \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class, - 'loadMessages', - \TYPO3\CMS\Belog\Controller\SystemInformationController::class, - 'appendMessage' - ); diff --git a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89733-SignalSlotsInCoreExtensionMigratedToPSR-14Events.rst b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89733-SignalSlotsInCoreExtensionMigratedToPSR-14Events.rst index 2ec0058af846026617d98fadc9d6f7c5c7d965c8..a44f9dcbe90eb93261081d9583d75ee9daa65db8 100644 --- a/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89733-SignalSlotsInCoreExtensionMigratedToPSR-14Events.rst +++ b/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89733-SignalSlotsInCoreExtensionMigratedToPSR-14Events.rst @@ -17,11 +17,13 @@ which are a 1:1 equivalent: - :php:`TYPO3\CMS\Core\Database\ReferenceIndex::shouldExcludeTableFromReferenceIndex` - :php:`TYPO3\CMS\Core\Utility\ExtensionManagementUtility::tcaIsBeingBuilt` - :php:`TYPO3\CMS\Install\Service\SqlExpectedSchemaService::tablesDefinitionIsBeingBuilt` -- :php:`\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::PostProcessTreeData` +- :php:`TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::PostProcessTreeData` +- :php:`TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::getSystemInformation` +- :php:`TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::loadMessages` In addition, the following public constant, marking a signal name, is deprecated: -- :php:`\TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::SIGNAL_PostProcessTreeData` +- :php:`TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::SIGNAL_PostProcessTreeData` Impact @@ -46,5 +48,6 @@ Use the new PSR-14 alternatives: - :php:`TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent` - :php:`TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent` - :php:`TYPO3\CMS\Core\Tree\Event\ModifyTreeDataEvent` +- :php:`TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent` .. index:: PHP-API, FullyScanned, ext:core diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-89733-NewPSR-14EventsForExistingSignalSlotsInCoreExtension.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-89733-NewPSR-14EventsForExistingSignalSlotsInCoreExtension.rst index 7529492de0fd63b6cd81171f9d676804239d81d9..078fd11018a2e15896f078586e4d887bad845514 100644 --- a/typo3/sysext/core/Documentation/Changelog/master/Feature-89733-NewPSR-14EventsForExistingSignalSlotsInCoreExtension.rst +++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-89733-NewPSR-14EventsForExistingSignalSlotsInCoreExtension.rst @@ -19,6 +19,7 @@ The following new PSR-14 events have been introduced: - :php:`TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent` - :php:`TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent` - :php:`TYPO3\CMS\Core\Tree\Event\ModifyTreeDataEvent` +- :php:`TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent` They replace the existing Extbase-based Signal Slots @@ -28,6 +29,8 @@ They replace the existing Extbase-based Signal Slots - :php:`TYPO3\CMS\Core\Utility\ExtensionManagementUtility::tcaIsBeingBuilt` - :php:`TYPO3\CMS\Install\Service\SqlExpectedSchemaService::tablesDefinitionIsBeingBuilt` - :php:`TYPO3\CMS\Core\Tree\TableConfiguration\DatabaseTreeDataProvider::PostProcessTreeData` +- :php:`TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::getSystemInformation` +- :php:`TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::loadMessages` Impact diff --git a/typo3/sysext/extbase/Classes/SignalSlot/Dispatcher.php b/typo3/sysext/extbase/Classes/SignalSlot/Dispatcher.php index 4d1df2e157a4febce2cab34aa714b3a63abbdbb7..1d239c58f40e46c6de1469f13d8de553241e397f 100644 --- a/typo3/sysext/extbase/Classes/SignalSlot/Dispatcher.php +++ b/typo3/sysext/extbase/Classes/SignalSlot/Dispatcher.php @@ -17,6 +17,8 @@ namespace TYPO3\CMS\Extbase\SignalSlot; */ use Psr\Log\LoggerInterface; +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; +use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; use TYPO3\CMS\Core\Configuration\Event\AfterTcaCompilationEvent; use TYPO3\CMS\Core\Database\Event\AlterTableDefinitionStatementsEvent; use TYPO3\CMS\Core\Database\ReferenceIndex; @@ -172,6 +174,10 @@ class Dispatcher implements \TYPO3\CMS\Core\SingletonInterface DatabaseTreeDataProvider::class => [ 'PostProcessTreeData' => ModifyTreeDataEvent::class, ], + SystemInformationToolbarItem::class => [ + 'getSystemInformation' => SystemInformationToolbarCollectorEvent::class, + 'loadMessages' => SystemInformationToolbarCollectorEvent::class + ] ]; /** diff --git a/typo3/sysext/install/Classes/SystemInformation/Typo3VersionMessage.php b/typo3/sysext/install/Classes/SystemInformation/Typo3VersionMessage.php index fbf52638a7bacba77bcf164bdf5360efdfb01dbb..1bf7af96a308ad0ab628d91d76b3be3f4850bfad 100644 --- a/typo3/sysext/install/Classes/SystemInformation/Typo3VersionMessage.php +++ b/typo3/sysext/install/Classes/SystemInformation/Typo3VersionMessage.php @@ -16,7 +16,7 @@ namespace TYPO3\CMS\Install\SystemInformation; * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Utility\LocalizationUtility; @@ -24,26 +24,19 @@ use TYPO3\CMS\Install\Service\CoreVersionService; use TYPO3\CMS\Install\Service\Exception\RemoteFetchException; /** - * Count newest exceptions for the system information menu + * Modifies the SystemInformation information to add a new message if you are running the latest TYPO3 Version * * @internal This class is only meant to be used within EXT:install and is not part of the TYPO3 Core API. */ -class Typo3VersionMessage +final class Typo3VersionMessage { - /** - * Modifies the SystemInformation array - * - * @param SystemInformationToolbarItem $systemInformationToolbarItem - */ - public function appendMessage(SystemInformationToolbarItem $systemInformationToolbarItem): void + public function appendMessage(SystemInformationToolbarCollectorEvent $event): void { + $systemInformationToolbarItem = $event->getToolbarItem(); $coreVersionService = GeneralUtility::makeInstance(CoreVersionService::class); - try { if ($coreVersionService->isVersionActivelyMaintained()) { - $isYoungerPatchReleaseAvailable = $coreVersionService->isYoungerPatchReleaseAvailable(); - - if (true === $isYoungerPatchReleaseAvailable) { + if ($coreVersionService->isYoungerPatchReleaseAvailable()) { $release = $coreVersionService->getYoungestPatchRelease(); if ($coreVersionService->isUpdateSecurityRelevant()) { diff --git a/typo3/sysext/install/Configuration/Services.yaml b/typo3/sysext/install/Configuration/Services.yaml new file mode 100644 index 0000000000000000000000000000000000000000..15f76349eb9f8ad387c25395a2ed65fe957e3d36 --- /dev/null +++ b/typo3/sysext/install/Configuration/Services.yaml @@ -0,0 +1,10 @@ +services: + TYPO3\CMS\Install\SystemInformation\Typo3VersionMessage: + autowire: true + autoconfigure: true + public: false + tags: + - name: event.listener + identifier: 'install/show-latest-errors' + method: 'appendMessage' + event: TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent diff --git a/typo3/sysext/install/ext_localconf.php b/typo3/sysext/install/ext_localconf.php index 825ef3052bb3ceb1f00e6e4dacd1771b1ab80cf3..72b5e6cb75b77b4f3fc5bf49741ee05e2acc72c2 100644 --- a/typo3/sysext/install/ext_localconf.php +++ b/typo3/sysext/install/ext_localconf.php @@ -73,11 +73,3 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['pr if (!\TYPO3\CMS\Core\Core\Environment::isCli()) { $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['system'][] = \TYPO3\CMS\Install\Report\EnvironmentStatusReport::class; } - -\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class) - ->connect( - \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class, - 'loadMessages', - \TYPO3\CMS\Install\SystemInformation\Typo3VersionMessage::class, - 'appendMessage' - ); diff --git a/typo3/sysext/scheduler/Classes/SystemInformation/ToolbarItemProvider.php b/typo3/sysext/scheduler/Classes/SystemInformation/ToolbarItemProvider.php index 2e4bcb0a05e6c726a8b72587a7168428db1f9614..68135a590b6847c348d227a9675568b691ff9808 100644 --- a/typo3/sysext/scheduler/Classes/SystemInformation/ToolbarItemProvider.php +++ b/typo3/sysext/scheduler/Classes/SystemInformation/ToolbarItemProvider.php @@ -15,7 +15,7 @@ namespace TYPO3\CMS\Scheduler\SystemInformation; * The TYPO3 project - inspiring people to share! */ -use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem; +use TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent; use TYPO3\CMS\Backend\Routing\UriBuilder; use TYPO3\CMS\Backend\Toolbar\Enumeration\InformationStatus; use TYPO3\CMS\Backend\Utility\BackendUtility; @@ -25,9 +25,9 @@ use TYPO3\CMS\Core\Registry; use TYPO3\CMS\Core\Utility\GeneralUtility; /** - * Add information about the scheduler configuration to the system information toolbar + * Event listener to display information about last automated run, as stored in the system registry. */ -class ToolbarItemProvider +final class ToolbarItemProvider { /** * Scheduler last run registry information @@ -44,13 +44,9 @@ class ToolbarItemProvider $this->lastRunInformation = GeneralUtility::makeInstance(Registry::class)->get('tx_scheduler', 'lastRun', []); } - /** - * Display information about last automated run, as stored in the system registry - * - * @param SystemInformationToolbarItem $systemInformationToolbarItem - */ - public function getItem(SystemInformationToolbarItem $systemInformationToolbarItem): void + public function getItem(SystemInformationToolbarCollectorEvent $event): void { + $systemInformationToolbarItem = $event->getToolbarItem(); // No tasks configured, so nothing is shown at all if (!$this->hasConfiguredTasks()) { return; @@ -119,7 +115,7 @@ class ToolbarItemProvider * * @return bool */ - protected function schedulerWasExecuted(): bool + private function schedulerWasExecuted(): bool { return !empty($this->lastRunInformation); } @@ -129,7 +125,7 @@ class ToolbarItemProvider * * @return bool */ - protected function lastRunInfoExists(): bool + private function lastRunInfoExists(): bool { return !empty($this->lastRunInformation['end']) || !empty($this->lastRunInformation['start']) @@ -141,7 +137,7 @@ class ToolbarItemProvider * * @return bool */ - protected function hasConfiguredTasks(): bool + private function hasConfiguredTasks(): bool { $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_scheduler_task'); $queryBuilder->getRestrictions()->removeAll(); @@ -157,7 +153,7 @@ class ToolbarItemProvider /** * @return LanguageService */ - protected function getLanguageService(): LanguageService + private function getLanguageService(): LanguageService { return $GLOBALS['LANG']; } diff --git a/typo3/sysext/scheduler/Configuration/Services.yaml b/typo3/sysext/scheduler/Configuration/Services.yaml index e8547339921d65d6d27709f2873f5715b0b8db1f..c719171541e8ba1cfde0467afba4cae5485b79aa 100644 --- a/typo3/sysext/scheduler/Configuration/Services.yaml +++ b/typo3/sysext/scheduler/Configuration/Services.yaml @@ -6,3 +6,10 @@ services: TYPO3\CMS\Scheduler\: resource: '../Classes/*' + + TYPO3\CMS\Scheduler\SystemInformation\ToolbarItemProvider: + tags: + - name: event.listener + identifier: 'scheduler/show-latest-errors' + method: 'getItem' + event: TYPO3\CMS\Backend\Backend\Event\SystemInformationToolbarCollectorEvent diff --git a/typo3/sysext/scheduler/ext_localconf.php b/typo3/sysext/scheduler/ext_localconf.php index ed3f42ac02dd6b2dc9320c87eabef1a9e1db1e73..1f8ab51df13942d9323789d7e6ca313b0ec6a439 100644 --- a/typo3/sysext/scheduler/ext_localconf.php +++ b/typo3/sysext/scheduler/ext_localconf.php @@ -132,12 +132,3 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['frequencyOptions'] = [ '*/20 * * * *' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example3', '0 7 * * 2' => 'LLL:EXT:scheduler/Resources/Private/Language/locallang.xlf:command.example4', ]; - -// Add system information toolbar item -\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\SignalSlot\Dispatcher::class) - ->connect( - \TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem::class, - 'getSystemInformation', - \TYPO3\CMS\Scheduler\SystemInformation\ToolbarItemProvider::class, - 'getItem' - );