Skip to content

Commit

Permalink
Use modern backend menug
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Oct 6, 2024
1 parent 117848c commit 92dbf51
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
36 changes: 30 additions & 6 deletions Classes/Controller/BackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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;
}
}
5 changes: 0 additions & 5 deletions Resources/Private/Partials/Backend/Menu.html

This file was deleted.

2 changes: 0 additions & 2 deletions Resources/Private/Templates/Backend/Boost.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

<f:section name="Content">

<f:render partial="Backend/Menu" />

<h1>
Boostmode
</h1>
Expand Down
3 changes: 0 additions & 3 deletions Resources/Private/Templates/Backend/List.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<f:layout name="Module"/>

<f:section name="Content">

<f:render partial="Backend/Menu" />

<h1>
<f:translate key="LLL:EXT:staticfilecache/Resources/Private/Language/locallang.xlf:module.title"/>
</h1>
Expand Down
3 changes: 0 additions & 3 deletions Resources/Private/Templates/Backend/Support.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<f:layout name="Module"/>

<f:section name="Content">

<f:render partial="Backend/Menu" />

<h1>
Support / Dokumentation
</h1>
Expand Down

0 comments on commit 92dbf51

Please sign in to comment.