Commit d12ca005 authored by Benni Mack's avatar Benni Mack

[TASK] Set ModuleTemplate details from request

This change adds a new ModuleTemplateFactory, which
is built with the Request in the object, allowing to use
the current request of the current action.

At the same time, all TYPO3 Core controllers
use proper DependencyInjection now, making it easier
to spot the dependencies and uses PSR-7 Request
where possible.

Resolves: #93885
Releases: master
Change-Id: Ia6594a1e68c5c27375f34e49bffeda4dcbc980d7
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68729Tested-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Reviewed-by: Oliver Hader's avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
parent d5a28bbe
......@@ -16,8 +16,10 @@
namespace TYPO3\CMS\Backend\Controller;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Information\Typo3Information;
use TYPO3\CMS\Core\Information\Typo3Version;
......@@ -46,30 +48,37 @@ class AboutController
*/
protected $view;
/**
* @var Typo3Version
*/
protected $version;
/**
* @var Typo3Information
*/
protected $typo3Information;
public function __construct(Typo3Version $version, Typo3Information $typo3Information)
{
protected Typo3Version $version;
protected Typo3Information $typo3Information;
protected ModuleLoader $moduleLoader;
protected PackageManager $packageManager;
protected ModuleTemplateFactory $moduleTemplateFactory;
public function __construct(
Typo3Version $version,
Typo3Information $typo3Information,
ModuleLoader $moduleLoader,
PackageManager $packageManager,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->version = $version;
$this->typo3Information = $typo3Information;
$this->moduleLoader = $moduleLoader;
$this->moduleLoader->observeWorkspaces = true;
$this->moduleLoader->load($GLOBALS['TBE_MODULES']);
$this->packageManager = $packageManager;
$this->moduleTemplateFactory = $moduleTemplateFactory;
}
/**
* Main action: Show standard information
*
* @param ServerRequestInterface $request
* @return ResponseInterface the HTML output
*/
public function indexAction(): ResponseInterface
public function indexAction(ServerRequestInterface $request): ResponseInterface
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->moduleTemplate = $this->moduleTemplateFactory->create($request);
$this->initializeView('index');
$warnings = [];
// Hook for additional warnings
......@@ -102,18 +111,15 @@ class AboutController
*/
protected function getModulesData(): array
{
$loadedModules = GeneralUtility::makeInstance(ModuleLoader::class);
$loadedModules->observeWorkspaces = true;
$loadedModules->load($GLOBALS['TBE_MODULES']);
$mainModulesData = [];
foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
$moduleLabels = $loadedModules->getLabelsForModule($moduleName);
foreach ($this->moduleLoader->modules as $moduleName => $moduleInfo) {
$moduleLabels = $this->moduleLoader->getLabelsForModule($moduleName);
$mainModuleData = [
'name' => $moduleName,
'label' => $moduleLabels['title']
];
if (is_array($moduleInfo['sub']) && !empty($moduleInfo['sub'])) {
$mainModuleData['subModules'] = $this->getSubModuleData($loadedModules, $moduleName);
$mainModuleData['subModules'] = $this->getSubModuleData((string)$moduleName);
}
$mainModulesData[] = $mainModuleData;
}
......@@ -123,19 +129,18 @@ class AboutController
/**
* Create array with data of all subModules of a specific main module
*
* @param ModuleLoader $loadedModules the module loader instance
* @param string $moduleName Name of the main module
* @return array
*/
protected function getSubModuleData(ModuleLoader $loadedModules, $moduleName): array
protected function getSubModuleData(string $moduleName): array
{
if (empty($loadedModules->modules[$moduleName]['sub'])) {
if (empty($this->moduleLoader->modules[$moduleName]['sub'])) {
return [];
}
$subModulesData = [];
foreach ($loadedModules->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
$moduleLabels = $loadedModules->getLabelsForModule($moduleName . '_' . $subModuleName);
foreach ($this->moduleLoader->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
$moduleLabels = $this->moduleLoader->getLabelsForModule($moduleName . '_' . $subModuleName);
$subModuleData = [];
$subModuleData['name'] = $subModuleName;
$subModuleData['icon'] = $subModuleInfo['icon'] ?? null;
......@@ -156,8 +161,7 @@ class AboutController
protected function getLoadedExtensions(): array
{
$extensions = [];
$packageManager = GeneralUtility::makeInstance(PackageManager::class);
foreach ($packageManager->getActivePackages() as $package) {
foreach ($this->packageManager->getActivePackages() as $package) {
// Skip system extensions (= type: typo3-cms-framework)
if ($package->getValueFromComposerManifest('type') !== 'typo3-cms-extension') {
continue;
......
......@@ -21,6 +21,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Authentication\Mfa\MfaProviderRegistry;
use TYPO3\CMS\Core\Localization\LanguageService;
......@@ -33,22 +34,23 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
*/
abstract class AbstractMfaController
{
protected ModuleTemplate $moduleTemplate;
protected UriBuilder $uriBuilder;
protected MfaProviderRegistry $mfaProviderRegistry;
protected ModuleTemplateFactory $moduleTemplateFactory;
protected ?ModuleTemplate $moduleTemplate;
protected array $mfaTsConfig;
protected bool $mfaRequired;
protected array $allowedProviders;
protected array $allowedActions = [];
public function __construct(
ModuleTemplate $moduleTemplate,
UriBuilder $uriBuilder,
MfaProviderRegistry $mfaProviderRegistry
MfaProviderRegistry $mfaProviderRegistry,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->moduleTemplate = $moduleTemplate;
$this->uriBuilder = $uriBuilder;
$this->mfaProviderRegistry = $mfaProviderRegistry;
$this->moduleTemplateFactory = $moduleTemplateFactory;
$this->initializeMfaConfiguration();
}
......
......@@ -21,7 +21,7 @@ use TYPO3\CMS\Backend\Domain\Repository\Module\BackendModuleRepository;
use TYPO3\CMS\Backend\Module\ModuleLoader;
use TYPO3\CMS\Backend\Routing\Router;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Toolbar\ToolbarItemInterface;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
......@@ -64,55 +64,38 @@ class BackendController
*/
protected $partialPath = 'EXT:backend/Resources/Private/Partials/';
/**
* @var BackendModuleRepository
*/
protected $backendModuleRepository;
/**
* @var PageRenderer
*/
protected $pageRenderer;
/**
* @var IconFactory
*/
protected $iconFactory;
/**
* @var Typo3Version
*/
protected $typo3Version;
/**
* @var UriBuilder
*/
protected $uriBuilder;
protected BackendModuleRepository $backendModuleRepository;
protected PageRenderer $pageRenderer;
protected IconFactory $iconFactory;
protected Typo3Version $typo3Version;
protected UriBuilder $uriBuilder;
protected ModuleLoader $moduleLoader;
protected ModuleTemplateFactory $moduleTemplateFactory;
/**
* @var \SplObjectStorage
*/
protected $moduleStorage;
/**
* @var ModuleLoader
*/
protected $moduleLoader;
/**
* Constructor
*/
public function __construct()
{
public function __construct(
Typo3Version $typo3Version,
IconFactory $iconFactory,
UriBuilder $uriBuilder,
PageRenderer $pageRenderer,
ModuleLoader $moduleLoader,
BackendModuleRepository $backendModuleRepository,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');
$this->backendModuleRepository = GeneralUtility::makeInstance(BackendModuleRepository::class);
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$this->typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
$this->pageRenderer = GeneralUtility::makeInstance(PageRenderer::class);
$this->moduleLoader = GeneralUtility::makeInstance(ModuleLoader::class);
$this->backendModuleRepository = $backendModuleRepository;
$this->iconFactory = $iconFactory;
$this->uriBuilder = $uriBuilder;
$this->typo3Version = $typo3Version;
$this->pageRenderer = $pageRenderer;
$this->moduleLoader = $moduleLoader;
$this->moduleLoader->observeWorkspaces = true;
$this->moduleLoader->load($GLOBALS['TBE_MODULES']);
$this->moduleTemplateFactory = $moduleTemplateFactory;
// Add default BE javascript
$this->pageRenderer->addJsFile('EXT:backend/Resources/Public/JavaScript/backend.js');
......@@ -209,7 +192,7 @@ class BackendController
$bodyTag = '<body class="scaffold t3js-scaffold' . (!$moduleMenuCollapsed && $hasModules ? ' scaffold-modulemenu-expanded' : '') . '">';
// Prepare the scaffolding, at this point extension may still add javascript and css
$moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$moduleTemplate = $this->moduleTemplateFactory->create($request);
$view = $moduleTemplate->getView();
$view->setPartialRootPaths([GeneralUtility::getFileAbsFileName('EXT:backend/Resources/Private/Partials')]);
$view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($this->templatePath . 'Backend/Main.html'));
......
......@@ -22,11 +22,13 @@ use TYPO3\CMS\Backend\History\RecordHistoryRollback;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\Components\ButtonBar;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\DataHandling\History\RecordHistoryStore;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\DiffUtility;
......@@ -74,9 +76,18 @@ class ElementHistoryController
*/
protected string $returnUrl = '';
public function __construct()
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
protected IconFactory $iconFactory;
protected UriBuilder $uriBuilder;
protected ModuleTemplateFactory $moduleTemplateFactory;
public function __construct(
IconFactory $iconFactory,
UriBuilder $uriBuilder,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->iconFactory = $iconFactory;
$this->uriBuilder = $uriBuilder;
$this->moduleTemplateFactory = $moduleTemplateFactory;
$this->view = $this->initializeView();
}
......@@ -89,6 +100,7 @@ class ElementHistoryController
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->moduleTemplate = $this->moduleTemplateFactory->create($request);
$backendUser = $this->getBackendUser();
$this->moduleTemplate->getDocHeaderComponent()->setMetaInformation([]);
$buttonBar = $this->moduleTemplate->getDocHeaderComponent()->getButtonBar();
......@@ -126,7 +138,7 @@ class ElementHistoryController
$this->displayMultipleDiff($completeDiff);
$button = $buttonBar->makeLinkButton()
->setHref($this->buildUrl(['historyEntry' => '']))
->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL))
->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL))
->setTitle($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_show_rechis.xlf:fullView'))
->setShowLabelText(true);
$buttonBar->addButton($button);
......@@ -151,7 +163,7 @@ class ElementHistoryController
'element' => 'pages:' . $parentPage['pid'],
'historyEntry' => '',
]))
->setIcon($this->moduleTemplate->getIconFactory()->getIcon('apps-pagetree-page-default', Icon::SIZE_SMALL))
->setIcon($this->iconFactory->getIcon('apps-pagetree-page-default', Icon::SIZE_SMALL))
->setTitle($this->getLanguageService()->sL('LLL:EXT:backend/Resources/Private/Language/locallang_show_rechis.xlf:elementHistory_link'))
->setShowLabelText(true);
$buttonBar->addButton($button, ButtonBar::BUTTON_POSITION_LEFT, 2);
......@@ -209,7 +221,7 @@ class ElementHistoryController
->setHref($this->returnUrl)
->setTitle($this->getLanguageService()->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:rm.closeDoc'))
->setShowLabelText(true)
->setIcon($this->moduleTemplate->getIconFactory()->getIcon('actions-close', Icon::SIZE_SMALL));
->setIcon($this->iconFactory->getIcon('actions-close', Icon::SIZE_SMALL));
$buttonBar->addButton($backButton, ButtonBar::BUTTON_POSITION_LEFT, 10);
}
}
......@@ -404,8 +416,7 @@ class ElementHistoryController
$params = array_merge($params, $overrideParameters);
// Make the link:
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
return (string)$uriBuilder->buildUriFromRoute('record_history', $params);
return (string)$this->uriBuilder->buildUriFromRoute('record_history', $params);
}
/**
......
......@@ -28,6 +28,7 @@ use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\PreviewUriBuilder;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Database\ConnectionPool;
......@@ -115,17 +116,18 @@ class ElementInformationController
*/
protected $folderObject;
/**
* @var IconFactory
*/
protected $iconFactory;
/**
* Constructor
*/
public function __construct()
{
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
protected IconFactory $iconFactory;
protected UriBuilder $uriBuilder;
protected ModuleTemplateFactory $moduleTemplateFactory;
public function __construct(
IconFactory $iconFactory,
UriBuilder $uriBuilder,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->iconFactory = $iconFactory;
$this->uriBuilder = $uriBuilder;
$this->moduleTemplateFactory = $moduleTemplateFactory;
}
/**
......@@ -150,14 +152,14 @@ class ElementInformationController
*/
protected function init(ServerRequestInterface $request): void
{
$this->moduleTemplate = $this->moduleTemplateFactory->create($request);
$this->moduleTemplate->getDocHeaderComponent()->disable();
$queryParams = $request->getQueryParams();
$this->table = $queryParams['table'] ?? null;
$this->uid = $queryParams['uid'] ?? null;
$this->permsClause = $this->getBackendUser()->getPagePermsClause(Permission::PAGE_SHOW);
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->moduleTemplate->getDocHeaderComponent()->disable();
if (isset($GLOBALS['TCA'][$this->table])) {
$this->initDatabaseRecord();
......@@ -607,19 +609,18 @@ class ElementInformationController
],
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$actions['recordEditUrl'] = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$actions['recordEditUrl'] = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
// History button
$urlParameters = [
'element' => $table . ':' . $uid,
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
];
$actions['recordHistoryUrl'] = (string)$uriBuilder->buildUriFromRoute('record_history', $urlParameters);
$actions['recordHistoryUrl'] = (string)$this->uriBuilder->buildUriFromRoute('record_history', $urlParameters);
if ($table === 'pages') {
// Recordlist button
$actions['webListUrl'] = (string)$uriBuilder->buildUriFromRoute('web_list', ['id' => $uid, 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()]);
$actions['webListUrl'] = (string)$this->uriBuilder->buildUriFromRoute('web_list', ['id' => $uid, 'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()]);
$previewUriBuilder = PreviewUriBuilder::create((int)$uid)
->withRootLine(BackendUtility::BEgetRootLine($uid));
......@@ -708,8 +709,7 @@ class ElementInformationController
],
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$line['url'] = $url;
$line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
$line['row'] = $row;
......@@ -789,8 +789,7 @@ class ElementInformationController
],
'returnUrl' => $request->getAttribute('normalizedParams')->getRequestUri()
];
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
$url = (string)$uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$url = (string)$this->uriBuilder->buildUriFromRoute('record_edit', $urlParameters);
$line['url'] = $url;
$line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
$line['row'] = $row;
......
......@@ -20,6 +20,7 @@ namespace TYPO3\CMS\Backend\Controller\ContentElement;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Tree\View\ContentMovingPagePositionMap;
use TYPO3\CMS\Backend\Tree\View\PageMovingPagePositionMap;
use TYPO3\CMS\Backend\Utility\BackendUtility;
......@@ -27,7 +28,9 @@ use TYPO3\CMS\Backend\View\BackendLayoutView;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
......@@ -94,6 +97,20 @@ class MoveElementController
*/
protected $moduleTemplate;
protected IconFactory $iconFactory;
protected PageRenderer $pageRenderer;
protected ModuleTemplateFactory $moduleTemplateFactory;
public function __construct(
IconFactory $iconFactory,
PageRenderer $pageRenderer,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->iconFactory = $iconFactory;
$this->pageRenderer = $pageRenderer;
$this->moduleTemplateFactory = $moduleTemplateFactory;
}
/**
* Injects the request object for the current request or subrequest
* As this controller goes only through the main() method, it is rather simple for now
......@@ -103,7 +120,7 @@ class MoveElementController
*/
public function mainAction(ServerRequestInterface $request): ResponseInterface
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->moduleTemplate = $this->moduleTemplateFactory->create($request);
$this->getLanguageService()->includeLLFile('EXT:core/Resources/Private/Language/locallang_misc.xlf');
$this->init($request);
$this->renderContent();
......@@ -142,7 +159,7 @@ class MoveElementController
if ($this->page_id) {
$assigns = [];
$backendUser = $this->getBackendUser();
$this->moduleTemplate->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
$this->pageRenderer->loadRequireJsModule('TYPO3/CMS/Backend/Tooltip');
// Get record for element:
$elRow = BackendUtility::getRecordWSOL($this->table, $this->moveUid);
// Headerline: Icon, record title:
......@@ -272,10 +289,7 @@ class MoveElementController
$backButton = $buttonBar->makeLinkButton()
->setHref($this->R_URI)
->setTitle($this->getLanguageService()->getLL('goBack'))
->setIcon($this->moduleTemplate->getIconFactory()->getIcon(
'actions-view-go-back',
Icon::SIZE_SMALL
));
->setIcon($this->iconFactory->getIcon('actions-view-go-back', Icon::SIZE_SMALL));
$buttonBar->addButton($backButton);
}
}
......
......@@ -21,6 +21,7 @@ use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Backend\Template\ModuleTemplate;
use TYPO3\CMS\Backend\Template\ModuleTemplateFactory;
use TYPO3\CMS\Backend\Tree\View\ContentCreationPagePositionMap;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Backend\View\BackendLayoutView;
......@@ -28,7 +29,9 @@ use TYPO3\CMS\Backend\Wizard\NewContentElementWizardHookInterface;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Imaging\IconFactory;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Service\DependencyOrderingService;
use TYPO3\CMS\Core\Type\Bitmask\Permission;
use TYPO3\CMS\Core\Utility\GeneralUtility;
......@@ -104,20 +107,21 @@ class NewContentElementController
*/
protected $moduleTemplate;
/**
* @var UriBuilder
*/
protected $uriBuilder;
/**
* Constructor
*/
public function __construct()
{
$this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
$this->view = $this->getFluidTemplateObject();
$this->menuItemView = $this->getFluidTemplateObject('MenuItem.html');
$this->uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
protected IconFactory $iconFactory;
protected PageRenderer $pageRenderer;
protected UriBuilder $uriBuilder;
protected ModuleTemplateFactory $moduleTemplateFactory;
public function __construct(
IconFactory $iconFactory,
PageRenderer $pageRenderer,
UriBuilder $uriBuilder,
ModuleTemplateFactory $moduleTemplateFactory
) {
$this->iconFactory = $iconFactory;
$this->pageRenderer = $pageRenderer;
$this->uriBuilder = $uriBuilder;
$this->moduleTemplateFactory = $moduleTemplateFactory;
}
/**
......@@ -127,6 +131,9 @@ class NewContentElementController
*/
protected function init(ServerRequestInterface $request)
{
$this->moduleTemplate = $this->moduleTemplateFactory->create($request);
$this->view = $this->getFluidTemplateObject();