Commit 22145c79 authored by Christian Kuhn's avatar Christian Kuhn Committed by Benjamin Franzke
Browse files

[TASK] Use composer name from request route

Since backend routes contain the package name
which defined a route, we can use this in backend
view related API and don't need to hand over the
composer name as argument anymore in most situations.

The patch thus simplifies the ModuleTemplateFactory
API and its usages, refactors BackendViewFactory,
and adds some functional tests to verify
BackendViewFactory template path override logic.

Resolves: #96962
Related: #96961
Related: #96730
Releases: main
Change-Id: I0787e21336f5a5f9b9a879555390dd5280a80024
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73598


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>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Benjamin Franzke's avatarBenjamin Franzke <bfr@qbus.de>
parent 5747c5b2
......@@ -106,7 +106,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface, RequestAwareToolbar
*/
public function getItem(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
if ($this->hasDropDown()) {
return $view->render('ToolbarItems/ClearCacheToolbarItem');
}
......@@ -124,7 +124,7 @@ class ClearCacheToolbarItem implements ToolbarItemInterface, RequestAwareToolbar
*/
public function getDropDown(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
$view->assign('cacheActions', $this->cacheActions);
return $view->render('ToolbarItems/ClearCacheToolbarItemDropDown');
}
......
......@@ -61,7 +61,7 @@ class HelpToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemIn
*/
public function getItem(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
return $view->render('ToolbarItems/HelpToolbarItem');
}
......@@ -74,7 +74,7 @@ class HelpToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemIn
// checkAccess() is called before and prevents call to getDropDown() if there is no help.
throw new \RuntimeException('No HelpModuleMenu found.', 1641993564);
}
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
$view->assign('modules', $this->helpModule->getSubModules());
return $view->render('ToolbarItems/HelpToolbarItemDropDown');
}
......
......@@ -56,7 +56,7 @@ class LiveSearchToolbarItem implements ToolbarItemInterface, RequestAwareToolbar
*/
public function getItem(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
return $view->render('ToolbarItems/LiveSearchToolbarItem');
}
......
......@@ -57,7 +57,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface, RequestAwareToolbarIt
*/
public function getItem(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
return $view->render('ToolbarItems/ShortcutToolbarItemItem');
}
......@@ -84,7 +84,7 @@ class ShortcutToolbarItem implements ToolbarItemInterface, RequestAwareToolbarIt
'shortcuts' => $this->shortcutRepository->getShortcutsByGroup($groupId),
];
}
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
$view->assign('shortcutMenu', $shortcutMenu);
return $view->render('ToolbarItems/ShortcutToolbarItemDropDown');
}
......
......@@ -121,7 +121,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface, RequestAware
*/
public function getItem(): string
{
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
return $view->render('ToolbarItems/SystemInformationToolbarItem');
}
......@@ -139,7 +139,7 @@ class SystemInformationToolbarItem implements ToolbarItemInterface, RequestAware
} catch (RouteNotFoundException $e) {
$environmentToolUrl = '';
}
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
$view->assignMultiple([
'environmentToolUrl' => $environmentToolUrl,
'messages' => $this->systemMessages,
......
......@@ -61,7 +61,7 @@ class UserToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemIn
public function getItem(): string
{
$backendUser = $this->getBackendUser();
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
$view->assignMultiple([
'currentUser' => $backendUser->user,
'switchUserMode' => (int)$backendUser->getOriginalUserIdWhenInSwitchUserMode(),
......@@ -113,7 +113,7 @@ class UserToolbarItem implements ToolbarItemInterface, RequestAwareToolbarItemIn
if ($userModule = $this->moduleProvider->getModuleForMenu('user', $backendUser)) {
$modules = $userModule->getSubModules();
}
$view = $this->backendViewFactory->create($this->request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($this->request);
$view->assignMultiple([
'modules' => $modules,
'switchUserMode' => $this->getBackendUser()->getOriginalUserIdWhenInSwitchUserMode() !== null,
......
......@@ -52,7 +52,7 @@ class AboutController
{
$event = new Event\ModifyGenericBackendMessagesEvent();
$event = $this->eventDispatcher->dispatch($event);
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$view = $this->moduleTemplateFactory->create($request);
$view->assignMultiple([
'typo3Info' => $this->typo3Information,
'typo3Version' => $this->version,
......
......@@ -138,7 +138,7 @@ class BackendController
$pageRenderer->setTitle($title);
$moduleMenuCollapsed = $this->getCollapseStateOfMenu();
$view = $this->viewFactory->create($request, 'typo3/cms-backend');
$view = $this->viewFactory->create($request);
$this->assignTopbarDetailsToView($request, $view);
$view->assignMultiple([
'modules' => $this->modules,
......@@ -161,7 +161,7 @@ class BackendController
*/
public function getModuleMenu(ServerRequestInterface $request): ResponseInterface
{
$view = $this->viewFactory->create($request, 'typo3/cms-backend');
$view = $this->viewFactory->create($request);
$view->assign('modules', $this->modules);
return new JsonResponse(['menu' => $view->render('Backend/ModuleMenu')]);
}
......@@ -172,7 +172,7 @@ class BackendController
*/
public function getTopbar(ServerRequestInterface $request): ResponseInterface
{
$view = $this->viewFactory->create($request, 'typo3/cms-backend');
$view = $this->viewFactory->create($request);
$this->assignTopbarDetailsToView($request, $view);
return new JsonResponse(['topbar' => $view->render('Backend/Topbar')]);
}
......
......@@ -96,7 +96,7 @@ class ColumnSelectorController
if ($table === '') {
throw new \RuntimeException('No table was given for selecting columns', 1625169125);
}
$view = $this->backendViewFactory->create($request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($request);
$view->assignMultiple([
'table' => $table,
'columns' => $this->getColumns($table, (int)($queryParams['id'] ?? 0)),
......
......@@ -82,7 +82,7 @@ class ElementHistoryController
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$this->view = $this->moduleTemplateFactory->create($request);
$backendUser = $this->getBackendUser();
$this->view->getDocHeaderComponent()->setMetaInformation([]);
$buttonBar = $this->view->getDocHeaderComponent()->getButtonBar();
......
......@@ -75,7 +75,7 @@ class ElementInformationController
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$backendUser = $this->getBackendUser();
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$view = $this->moduleTemplateFactory->create($request);
$view->getDocHeaderComponent()->disable();
$queryParams = $request->getQueryParams();
$this->table = $queryParams['table'] ?? null;
......
......@@ -55,7 +55,7 @@ class MoveElementController
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$view = $this->moduleTemplateFactory->create($request);
$parsedBody = $request->getParsedBody();
$queryParams = $request->getQueryParams();
......
......@@ -213,7 +213,7 @@ class NewContentElementController
}
}
$view = $this->backendViewFactory->create($request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($request);
$view->assignMultiple([
'positionSelection' => $positionSelection,
'tabsMenuItems' => $menuItems,
......@@ -232,7 +232,7 @@ class NewContentElementController
$posMap->defVals = (array)($request->getParsedBody()['defVals'] ?? []);
$posMap->saveAndClose = (bool)($request->getParsedBody()['saveAndClose'] ?? false);
$posMap->R_URI = $this->R_URI;
$view = $this->backendViewFactory->create($request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($request);
$view->assign('posMap', $posMap->printContentElementColumns($this->id));
return new HtmlResponse($view->render('NewContentElement/PositionMap'));
}
......
......@@ -36,7 +36,7 @@ class DummyController
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle('Blank');
$view->getDocHeaderComponent()->disable();
return $view->renderResponse('Dummy/Index');
......
......@@ -354,7 +354,7 @@ class EditDocumentController
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$view = $this->moduleTemplateFactory->create($request);
$view->setUiBlock(true);
$view->setTitle($this->getShortcutTitle($request));
......
......@@ -75,7 +75,7 @@ class HelpController
if (!in_array($action, self::ALLOWED_ACTIONS, true)) {
return new HtmlResponse('Action not allowed', 400);
}
$view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$view = $this->moduleTemplateFactory->create($request);
$view->setTitle($this->getShortcutTitle($request));
return $this->{$action . 'Action'}($view, $request);
}
......
......@@ -63,7 +63,7 @@ class MfaConfigurationController extends AbstractMfaController
public function handleRequest(ServerRequestInterface $request): ResponseInterface
{
$this->initializeMfaConfiguration();
$this->view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$this->view = $this->moduleTemplateFactory->create($request);
$action = (string)($request->getQueryParams()['action'] ?? $request->getParsedBody()['action'] ?? 'overview');
if (!$this->isActionAllowed($action)) {
......
......@@ -88,7 +88,7 @@ class MfaController extends AbstractMfaController
$this->setUpBasicPageRendererForBackend($this->pageRenderer, $this->extensionConfiguration, $request, $this->getLanguageService());
$this->pageRenderer->setTitle('TYPO3 CMS Login: ' . ($GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'] ?? ''));
$this->pageRenderer->loadJavaScriptModule('bootstrap');
$view = $this->backendViewFactory->create($request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($request);
$propertyManager = MfaProviderPropertyManager::create($mfaProvider, $this->getBackendUser());
$providerResponse = $mfaProvider->handleRequest($request, $propertyManager, MfaViewType::AUTH);
$view->assignMultiple([
......
......@@ -206,7 +206,7 @@ class MfaSetupController extends AbstractMfaController
*/
protected function initializeView(ServerRequestInterface $request): ViewInterface
{
$view = $this->backendViewFactory->create($request, 'typo3/cms-backend');
$view = $this->backendViewFactory->create($request);
$view->assignMultiple([
'redirect' => $request->getQueryParams()['redirect'] ?? '',
'redirectParams' => $request->getQueryParams()['redirectParams'] ?? '',
......
......@@ -188,7 +188,7 @@ class NewRecordController
*/
protected function init(ServerRequestInterface $request): void
{
$this->view = $this->moduleTemplateFactory->create($request, 'typo3/cms-backend');
$this->view = $this->moduleTemplateFactory->create($request);
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');
$beUser = $this->getBackendUserAuthentication();
// Page-selection permission clause (reading)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment