43d1f3d01eb58e73feaab8f9a7fa6a80d7f594c1
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / AbstractController.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Install\Controller;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use Psr\Http\Message\ServerRequestInterface;
19 use TYPO3\CMS\Core\Utility\GeneralUtility;
20 use TYPO3\CMS\Fluid\View\StandaloneView;
21
22 /**
23 * Controller abstract for shared parts of the install tool
24 * @internal This class is a specific controller implementation and is not considered part of the Public TYPO3 API.
25 */
26 class AbstractController
27 {
28 /**
29 * Helper method to initialize a standalone view instance.
30 *
31 * @param ServerRequestInterface $request
32 * @param string $templatePath
33 * @return StandaloneView
34 * @internal param string $template
35 */
36 protected function initializeStandaloneView(ServerRequestInterface $request, string $templatePath): StandaloneView
37 {
38 $viewRootPath = GeneralUtility::getFileAbsFileName('EXT:install/Resources/Private/');
39 $view = GeneralUtility::makeInstance(StandaloneView::class);
40 $view->getRequest()->setControllerExtensionName('Install');
41 $view->setTemplatePathAndFilename($viewRootPath . 'Templates/' . $templatePath);
42 $view->setLayoutRootPaths([$viewRootPath . 'Layouts/']);
43 $view->setPartialRootPaths([$viewRootPath . 'Partials/']);
44 $view->assignMultiple([
45 'controller' => $request->getQueryParams()['install']['controller'] ?? 'maintenance',
46 'context' => $request->getQueryParams()['install']['context'] ?? '',
47 ]);
48 return $view;
49 }
50
51 /**
52 * Some actions like the database analyzer and the upgrade wizards need additional
53 * bootstrap actions performed.
54 *
55 * Those actions can potentially fatal if some old extension is loaded that triggers
56 * a fatal in ext_localconf or ext_tables code! Use only if really needed.
57 */
58 protected function loadExtLocalconfDatabaseAndExtTables()
59 {
60 \TYPO3\CMS\Core\Core\Bootstrap::loadTypo3LoadedExtAndExtLocalconf(false);
61 \TYPO3\CMS\Core\Core\Bootstrap::unsetReservedGlobalVariables();
62 \TYPO3\CMS\Core\Core\Bootstrap::loadBaseTca(false);
63 \TYPO3\CMS\Core\Core\Bootstrap::loadExtTables(false);
64 }
65 }