From 92dbf51ef812c07c96bb2ac73b5fb2433c35db10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochm=C3=BCller?= Date: Sun, 6 Oct 2024 22:35:35 +0200 Subject: [PATCH] Use modern backend menug --- Classes/Controller/BackendController.php | 36 +++++++++++++++---- Resources/Private/Partials/Backend/Menu.html | 5 --- .../Private/Templates/Backend/Boost.html | 2 -- Resources/Private/Templates/Backend/List.html | 3 -- .../Private/Templates/Backend/Support.html | 3 -- 5 files changed, 30 insertions(+), 19 deletions(-) delete mode 100644 Resources/Private/Partials/Backend/Menu.html diff --git a/Classes/Controller/BackendController.php b/Classes/Controller/BackendController.php index b6a627958d9..ab00e4e4ebe 100644 --- a/Classes/Controller/BackendController.php +++ b/Classes/Controller/BackendController.php @@ -6,6 +6,8 @@ use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; +use TYPO3\CMS\Backend\Template\Components\Menu\Menu; +use TYPO3\CMS\Backend\Template\Components\Menu\MenuItem; use TYPO3\CMS\Core\Type\ContextualFeedbackSeverity; use TYPO3\CMS\Core\Messaging\AbstractMessage; use Psr\Http\Message\ResponseInterface; @@ -29,9 +31,9 @@ class BackendController extends ActionController implements LoggerAwareInterface use LoggerAwareTrait; public function __construct( - readonly protected QueueService $queueService, + readonly protected QueueService $queueService, readonly protected ModuleTemplateFactory $moduleTemplateFactory, - readonly protected ConfigurationService $configurationService + readonly protected ConfigurationService $configurationService ) {} public function listAction(string $filter = ''): ResponseInterface @@ -67,8 +69,8 @@ public function boostAction(bool $run = false): ResponseInterface } $viewVariables = [ 'enable' => (bool) $this->configurationService->get('boostMode'), - 'open' => \count($queueRepository->findOpen(99999999)), - 'old' => \count($queueRepository->findOldUids()), + 'open' => \count(iterator_to_array($queueRepository->findOpen(99999999))), + 'old' => \count(iterator_to_array($queueRepository->findOldUids())), ]; return $this->createModuleTemplate() @@ -171,8 +173,30 @@ protected function getCurrentUid(): int protected function createModuleTemplate(): ModuleTemplate { - return $this->moduleTemplateFactory->create($this->request) + $moduleTemplate = $this->moduleTemplateFactory->create($this->request) ->setFlashMessageQueue($this->getFlashMessageQueue()) - ->setModuleClass('tx-staticfilecache'); + ->setModuleClass('tx-staticfilecache') + ->setTitle('StaticFileCache'); + + $menuItems = [ + 'list' => 'List (Overview)', + 'boost' => 'Boostmode', + 'support' => 'Configuration, Support, Documentation...', + ]; + + $menu = new Menu(); + $menu->setIdentifier('func'); + foreach ($menuItems as $action => $label) { + $menuItem = $menu->makeMenuItem() + ->setTitle($label) + ->setHref($this->uriBuilder->uriFor($action)) + ->setActive($this->request->getControllerActionName() === $action); + + $menu->addMenuItem($menuItem); + } + + $moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu); + + return $moduleTemplate; } } diff --git a/Resources/Private/Partials/Backend/Menu.html b/Resources/Private/Partials/Backend/Menu.html deleted file mode 100644 index 0b1fdce35ed..00000000000 --- a/Resources/Private/Partials/Backend/Menu.html +++ /dev/null @@ -1,5 +0,0 @@ -
- List (Overview) - Boostmode - Configuration, Support, Documentation... -
diff --git a/Resources/Private/Templates/Backend/Boost.html b/Resources/Private/Templates/Backend/Boost.html index fb4857222c2..bb02080e62a 100644 --- a/Resources/Private/Templates/Backend/Boost.html +++ b/Resources/Private/Templates/Backend/Boost.html @@ -2,8 +2,6 @@ - -

Boostmode

diff --git a/Resources/Private/Templates/Backend/List.html b/Resources/Private/Templates/Backend/List.html index 122c342a4f4..f468902e2fa 100644 --- a/Resources/Private/Templates/Backend/List.html +++ b/Resources/Private/Templates/Backend/List.html @@ -1,9 +1,6 @@ - - -

diff --git a/Resources/Private/Templates/Backend/Support.html b/Resources/Private/Templates/Backend/Support.html index dd063891337..68303d42718 100644 --- a/Resources/Private/Templates/Backend/Support.html +++ b/Resources/Private/Templates/Backend/Support.html @@ -1,9 +1,6 @@ - - -

Support / Dokumentation