Commit 25773e86 authored by Christian Kuhn's avatar Christian Kuhn
Browse files

[!!!][FEATURE] Avoid BackendTemplateView

Class BackendTemplateView has been a temporary solution
to simplify the implementation of the "TsConfig template
override" feature into smaller patches.

With ModuleTemplate and general view works being mostly
done in the backend, BackendTemplateView should be
removed again.

The patch removes all usages switching nearly all views
to BackendViewFactory, which removes the explicit
dependency to Typo3Fluid ViewInterface since the
EXT:core ViewInterface is not directly bound to Fluid
anymore.

Using BackendViewFactory has the additional advantage
that templates which don't use ModuleTemplate because
they're hook usages or some other "sub-view", can now
be overridden with TsConfig, too.

Using BackendViewFactory also makes the dependency to
ServerRequestInterface explicit. The patch thus hands
$request around at some more places where $request was
only an indirect dependency before.

One special @todo area is FormEngine, which is unable
to have dependency injection (for BackendViewFactory)
due to its manual constructor arguments. The patch
falls back to Typo3Fluid TemplateView in those cases.
The FormEngine API should be adapted with another patch.

Change-Id: Ie8959dada4dc6fd30e04d87fea6004e74cbe5990
Resolves: #96904
Related: #96730
Related: #96513
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73518


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Tested-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 720e8dd6
......@@ -35,11 +35,6 @@ parameters:
count: 1
path: ../../typo3/sysext/backend/Classes/Controller/ColumnSelectorController.php
-
message: "#^Method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:render\\(\\) invoked with 1 parameter, 0 required\\.$#"
count: 1
path: ../../typo3/sysext/backend/Classes/Controller/ColumnSelectorController.php
-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Core\\\\Resource\\\\FolderInterface\\:\\:getReadablePath\\(\\)\\.$#"
count: 1
......@@ -3785,11 +3780,6 @@ parameters:
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/Transform/HtmlViewHelper.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\Core\\\\Rendering\\\\RenderingContextInterface\\:\\:getRequest\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/fluid/Classes/ViewHelpers/TranslateViewHelper.php
-
message: "#^Call to an undefined method TYPO3\\\\CMS\\\\Extbase\\\\Mvc\\\\RequestInterface\\:\\:getControllerExtensionName\\(\\)\\.$#"
count: 1
......@@ -5255,11 +5245,6 @@ parameters:
count: 1
path: ../../typo3/sysext/recordlist/Classes/Controller/ClearPageCacheController.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/FileLinkHandler.php
-
message: "#^Property TYPO3\\\\CMS\\\\Recordlist\\\\LinkHandler\\\\FileLinkHandler\\:\\:\\$expandFolder \\(string\\) in isset\\(\\) is not nullable\\.$#"
count: 1
......@@ -5270,31 +5255,6 @@ parameters:
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/FolderLinkHandler.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/MailLinkHandler.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/PageLinkHandler.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/RecordLinkHandler.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/TelephoneLinkHandler.php
-
message: "#^Call to an undefined method TYPO3Fluid\\\\Fluid\\\\View\\\\ViewInterface\\:\\:setTemplate\\(\\)\\.$#"
count: 1
path: ../../typo3/sysext/recordlist/Classes/LinkHandler/UrlLinkHandler.php
-
message: "#^Cannot assign offset 'currentValue' to string\\.$#"
count: 1
......
......@@ -18,26 +18,29 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Backend\Event\ModifyClearCacheActionsEvent;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
/**
* Render cache clearing toolbar item.
* Adds a dropdown if there are more than one item to clear (usually for admins to render the flush all caches).
* The dropdown items can be manipulated using ModifyClearCacheActionsEvent.
*/
class ClearCacheToolbarItem implements ToolbarItemInterface
class ClearCacheToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemInterface
{
protected array $cacheActions = [];
protected array $optionValues = [];
private ServerRequestInterface $request;
public function __construct(
UriBuilder $uriBuilder,
EventDispatcherInterface $eventDispatcher
EventDispatcherInterface $eventDispatcher,
private readonly BackendViewFactory $backendViewFactory,
) {
$isAdmin = $this->getBackendUser()->isAdmin();
$userTsConfig = $this->getBackendUser()->getTSConfig();
......@@ -76,6 +79,11 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
$this->optionValues = $event->getCacheActionIdentifiers();
}
public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
/**
* Checks whether the user has access to this toolbar item.
*/
......@@ -98,10 +106,10 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
*/
public function getItem(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
if ($this->hasDropDown()) {
return $this->getFluidTemplateObject()->render('ToolbarItems/ClearCacheToolbarItem');
return $view->render('ToolbarItems/ClearCacheToolbarItem');
}
$view = $this->getFluidTemplateObject();
$cacheAction = end($this->cacheActions);
$view->assignMultiple([
'link' => $cacheAction['href'],
......@@ -116,7 +124,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
*/
public function getDropDown(): string
{
$view = $this->getFluidTemplateObject();
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view->assign('cacheActions', $this->cacheActions);
return $view->render('ToolbarItems/ClearCacheToolbarItemDropDown');
}
......@@ -145,14 +153,6 @@ class ClearCacheToolbarItem implements ToolbarItemInterface
return 25;
}
protected function getFluidTemplateObject(): BackendTemplateView
{
$view = GeneralUtility::makeInstance(BackendTemplateView::class);
$view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials']);
$view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates']);
return $view;
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
......
......@@ -17,28 +17,37 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\MenuModule;
use TYPO3\CMS\Backend\Module\ModuleProvider;
use TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
/**
* Help toolbar item - The question mark icon in toolbar
*/
class HelpToolbarItem implements ToolbarItemInterface
class HelpToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemInterface
{
protected ?MenuModule $helpModule = null;
private ServerRequestInterface $request;
public function __construct(ModuleProvider $moduleProvider)
{
public function __construct(
ModuleProvider $moduleProvider,
private readonly BackendViewFactory $backendViewFactory,
) {
$helpModule = $moduleProvider->getModuleForMenu('help', $this->getBackendUser());
if ($helpModule && $helpModule->hasSubModules()) {
$this->helpModule = $helpModule;
}
}
public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
/**
* Users see this if a module is available
*/
......@@ -52,7 +61,8 @@ class HelpToolbarItem implements ToolbarItemInterface
*/
public function getItem(): string
{
return $this->getFluidTemplateObject()->render('ToolbarItems/HelpToolbarItem');
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
return $view->render('ToolbarItems/HelpToolbarItem');
}
/**
......@@ -64,7 +74,7 @@ class HelpToolbarItem implements ToolbarItemInterface
// checkAccess() is called before and prevents call to getDropDown() if there is no help.
throw new \RuntimeException('No HelpModuleMenu found.', 1641993564);
}
$view = $this->getFluidTemplateObject();
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view->assign('modules', $this->helpModule->getSubModules());
return $view->render('ToolbarItems/HelpToolbarItemDropDown');
}
......@@ -93,14 +103,6 @@ class HelpToolbarItem implements ToolbarItemInterface
return 70;
}
protected function getFluidTemplateObject(): BackendTemplateView
{
$view = GeneralUtility::makeInstance(BackendTemplateView::class);
$view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials']);
$view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates']);
return $view;
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
......
......@@ -17,19 +17,29 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\ModuleProvider;
use TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
/**
* Adds backend live search to the toolbar by adding JavaScript and adding an input search field
*/
class LiveSearchToolbarItem implements ToolbarItemInterface
class LiveSearchToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemInterface
{
public function __construct(protected readonly ModuleProvider $moduleProvider)
private ServerRequestInterface $request;
public function __construct(
private readonly ModuleProvider $moduleProvider,
private readonly BackendViewFactory $backendViewFactory,
) {
}
public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
/**
......@@ -46,8 +56,7 @@ class LiveSearchToolbarItem implements ToolbarItemInterface
*/
public function getItem(): string
{
$view = GeneralUtility::makeInstance(BackendTemplateView::class);
$view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates']);
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
return $view->render('ToolbarItems/LiveSearchToolbarItem');
}
......
......@@ -17,25 +17,31 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Backend\Shortcut\ShortcutRepository;
use TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
/**
* Class to render the shortcut menu toolbar.
*
* @internal This class is a specific Backend implementation and is not considered part of the Public TYPO3 API.
*/
class ShortcutToolbarItem implements ToolbarItemInterface
class ShortcutToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemInterface
{
protected ShortcutRepository $shortcutRepository;
private ServerRequestInterface $request;
public function __construct(
ShortcutRepository $shortcutRepository
private readonly ShortcutRepository $shortcutRepository,
private readonly BackendViewFactory $backendViewFactory,
) {
$this->shortcutRepository = $shortcutRepository;
}
public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
/**
......@@ -51,7 +57,8 @@ class ShortcutToolbarItem implements ToolbarItemInterface
*/
public function getItem(): string
{
return $this->getFluidTemplateObject()->render('ToolbarItems/ShortcutToolbarItemItem');
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
return $view->render('ToolbarItems/ShortcutToolbarItemItem');
}
/**
......@@ -77,9 +84,9 @@ class ShortcutToolbarItem implements ToolbarItemInterface
'shortcuts' => $this->shortcutRepository->getShortcutsByGroup($groupId),
];
}
$dropDownView = $this->getFluidTemplateObject();
$dropDownView->assign('shortcutMenu', $shortcutMenu);
return $dropDownView->render('ToolbarItems/ShortcutToolbarItemDropDown');
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view->assign('shortcutMenu', $shortcutMenu);
return $view->render('ToolbarItems/ShortcutToolbarItemDropDown');
}
/**
......@@ -98,13 +105,6 @@ class ShortcutToolbarItem implements ToolbarItemInterface
return 20;
}
protected function getFluidTemplateObject(): BackendTemplateView
{
$view = GeneralUtility::makeInstance(BackendTemplateView::class);
$view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates']);
return $view;
}
protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
......
......@@ -18,10 +18,13 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Http\Message\ServerRequestInterface;
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\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Database\ConnectionPool;
......@@ -30,35 +33,34 @@ use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Routing\RouteNotFoundException;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
/**
* Render system information toolbar item and drop-down.
* Provides some events for other extensions to add information.
*/
class SystemInformationToolbarItem implements ToolbarItemInterface
class SystemInformationToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemInterface
{
private ServerRequestInterface $request;
protected array $systemInformation = [];
protected InformationStatus $highestSeverity;
protected string $severityBadgeClass = '';
protected array $systemMessages = [];
protected int $systemMessageTotalCount = 0;
protected EventDispatcherInterface $eventDispatcher;
protected Typo3Version $typo3Version;
protected UriBuilder $uriBuilder;
public function __construct(
EventDispatcherInterface $eventDispatcher,
Typo3Version $typo3Version,
UriBuilder $uriBuilder
private readonly EventDispatcherInterface $eventDispatcher,
private readonly Typo3Version $typo3Version,
private readonly UriBuilder $uriBuilder,
private readonly BackendViewFactory $backendViewFactory,
) {
$this->eventDispatcher = $eventDispatcher;
$this->typo3Version = $typo3Version;
$this->uriBuilder = $uriBuilder;
$this->highestSeverity = InformationStatus::cast(InformationStatus::STATUS_INFO);
}
public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
/**
* Add a system message.
* This is a callback method for signal receivers.
......@@ -119,7 +121,8 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
*/
public function getItem(): string
{
return $this->getFluidTemplateObject()->render('ToolbarItems/SystemInformationToolbarItem');
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
return $view->render('ToolbarItems/SystemInformationToolbarItem');
}
/**
......@@ -136,7 +139,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
} catch (RouteNotFoundException $e) {
$environmentToolUrl = '';
}
$view = $this->getFluidTemplateObject();
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view->assignMultiple([
'environmentToolUrl' => $environmentToolUrl,
'messages' => $this->systemMessages,
......@@ -342,15 +345,6 @@ class SystemInformationToolbarItem implements ToolbarItemInterface
return false;
}
protected function getFluidTemplateObject(): BackendTemplateView
{
$view = GeneralUtility::makeInstance(BackendTemplateView::class);
$view->setLayoutRootPaths(['EXT:backend/Resources/Private/Layouts']);
$view->setPartialRootPaths(['EXT:backend/Resources/Private/Partials']);
$view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates']);
return $view;
}
protected function getBackendUserAuthentication(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
......
......@@ -17,23 +17,34 @@ declare(strict_types=1);
namespace TYPO3\CMS\Backend\Backend\ToolbarItems;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\ModuleProvider;
use TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
/**
* User toolbar item and drop-down.
*
* @internal This class is a specific Backend implementation and is not considered part of the Public TYPO3 API.
*/
class UserToolbarItem implements ToolbarItemInterface
class UserToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemInterface
{
public function __construct(protected readonly ModuleProvider $moduleProvider)
private ServerRequestInterface $request;
public function __construct(
private readonly ModuleProvider $moduleProvider,
private readonly BackendViewFactory $backendViewFactory,
) {
}
public function setRequest(ServerRequestInterface $request): void
{
$this->request = $request;
}
/**
......@@ -50,7 +61,7 @@ class UserToolbarItem implements ToolbarItemInterface
public function getItem(): string
{
$backendUser = $this->getBackendUser();
$view = $this->getFluidTemplateObject();
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view->assignMultiple([
'currentUser' => $backendUser->user,
'switchUserMode' => (int)$backendUser->getOriginalUserIdWhenInSwitchUserMode(),
......@@ -102,7 +113,7 @@ class UserToolbarItem implements ToolbarItemInterface
if ($userModule = $this->moduleProvider->getModuleForMenu('user', $backendUser)) {
$modules = $userModule->getSubModules();
}
$view = $this->getFluidTemplateObject();
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view->assignMultiple([
'modules' => $modules,
'switchUserMode' => $this->getBackendUser()->getOriginalUserIdWhenInSwitchUserMode() !== null,
......@@ -145,11 +156,4 @@ class UserToolbarItem implements ToolbarItemInterface
{
return $GLOBALS['BE_USER'];
}
protected function getFluidTemplateObject(): BackendTemplateView
{
$view = GeneralUtility::makeInstance(BackendTemplateView::class);
$view->setTemplateRootPaths(['EXT:backend/Resources/Private/Templates']);
return $view;
}
}
......@@ -25,7 +25,7 @@ use TYPO3\CMS\Backend\Routing\Router;
use TYPO3\CMS\Backend\Routing\RouteRedirect;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\PageRendererBackendSetupTrait;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\RequestAwareToolbarItemInterface;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemsRegistry;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
......@@ -139,7 +139,7 @@ class BackendController
$moduleMenuCollapsed = $this->getCollapseStateOfMenu();
$view = $this->viewFactory->create($request, 'typo3/cms-backend');
$this->assignTopbarDetailsToView($view);
$this->assignTopbarDetailsToView($request, $view);
$view->assignMultiple([
'modules' => $this->modules,
'startupModule' => $this->getStartupModule($request),
......@@ -173,7 +173,7 @@ class BackendController
public function getTopbar(ServerRequestInterface $request): ResponseInterface
{
$view = $this->viewFactory->create($request, 'typo3/cms-backend');
$this->assignTopbarDetailsToView($view);
$this->assignTopbarDetailsToView($request, $view);
return new JsonResponse(['topbar' => $view->render('Backend/Topbar')]);
}
......@@ -190,7 +190,7 @@ class BackendController
/**
* Renders the topbar, containing the backend logo, sitename etc.
*/
protected function assignTopbarDetailsToView(ViewInterface $view): void
protected function assignTopbarDetailsToView(ServerRequestInterface $request, ViewInterface $view): void
{
// Extension Configuration to find the TYPO3 logo in the left corner
$extConf = $this->extensionConfiguration->get('backend');
......@@ -224,7 +224,7 @@ class BackendController
$view->assign('logoHeight', $logoHeight);
$view->assign('applicationVersion', $this->typo3Version->getVersion());
$view->assign('siteName', $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']);
$view->assign('toolbar', $this->renderToolbar());
$view->assign('toolbar', $this->renderToolbar($request));
}
/**
......@@ -232,12 +232,14 @@ class BackendController
*
* @todo: Inline this to the topbar template
*/
protected function renderToolbar(): string
protected function renderToolbar(ServerRequestInterface $request): string
{
$toolbarItems = $this->toolbarItemsRegistry->getToolbarItems();
$toolbar = [];
foreach ($toolbarItems as $toolbarItem) {
/** @var ToolbarItemInterface $toolbarItem */
if ($toolbarItem instanceof RequestAwareToolbarItemInterface) {
$toolbarItem->setRequest($request);
}
if ($toolbarItem->checkAccess()) {
$hasDropDown = (bool)$toolbarItem->hasDropDown();
$additionalAttributes = (array)$toolbarItem->getAdditionalAttributes();
......
......@@ -21,11 +21,10 @@ use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendViewFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\BackendTemplateView;
use TYPO3Fluid\Fluid\View\ViewInterface;
use TYPO3\CMS\Core\View\ViewInterface;
/**
* Controller for handling the display column selection for records, typically executed from list modules.
......@@ -48,8 +47,10 @@ class ColumnSelectorController
't3ver_oid', // Not relevant in listing
];
public function __construct(protected ResponseFactoryInterface $responseFactory)
{
public function __construct(
protected readonly ResponseFactoryInterface $responseFactory,
protected readonly BackendViewFactory $backendViewFactory,
) {
}