‪TYPO3CMS  ‪main
LayoutController.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
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 
19 
20 use Psr\Http\Message\ResponseInterface;
21 use Psr\Http\Message\ServerRequestInterface;
35 
44 {
46 
50 
51  public function ‪__construct(
55  ) {
56  $this->packageManager = ‪$packageManager;
57  $this->silentConfigurationUpgradeService = ‪$silentConfigurationUpgradeService;
58  $this->silentTemplateFileUpgradeService = ‪$silentTemplateFileUpgradeService;
59  }
60 
65  public function ‪initAction(ServerRequestInterface $request): ResponseInterface
66  {
67  $bust = ‪$GLOBALS['EXEC_TIME'];
68  if (!‪Environment::getContext()->isDevelopment()) {
70  }
71 
72  $packages = [
73  $this->packageManager->getPackage('core'),
74  $this->packageManager->getPackage('backend'),
75  $this->packageManager->getPackage('install'),
76  ];
77  $importMap = new ImportMap($packages);
78  $sitePath = $request->getAttribute('normalizedParams')->getSitePath();
79  $initModule = $sitePath . $importMap->resolveImport('@typo3/install/init-install.js');
80 
81  $view = $this->‪initializeView($request);
82  $nonce = ‪Nonce::create();
83  $view->assignMultiple([
84  // time is used as cache bust for js and css resources
85  'bust' => $bust,
86  'siteName' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
87  'initModule' => $initModule,
88  'importmap' => $importMap->render($sitePath, $nonce->b64),
89  ]);
90  return new HtmlResponse(
91  $view->render('Layout/Init'),
92  200,
93  [
94  'Cache-Control' => 'no-cache, must-revalidate',
95  'Content-Security-Policy' => $this->createContentSecurityPolicy()->compile($nonce),
96  'Pragma' => 'no-cache',
97  ]
98  );
99  }
100 
106  public function ‪mainLayoutAction(ServerRequestInterface $request): ResponseInterface
107  {
108  $view = $this->‪initializeView($request);
109  $view->assign('moduleName', 'tools_tools' . ($request->getQueryParams()['install']['module'] ?? 'layout'));
110  return new JsonResponse([
111  'success' => true,
112  'html' => $view->render('Layout/MainLayout'),
113  ]);
114  }
115 
121  public function ‪executeSilentConfigurationUpdateAction(): ResponseInterface
122  {
123  $success = true;
124  try {
125  $this->silentConfigurationUpgradeService->execute();
126  } catch (ConfigurationChangedException $e) {
127  $success = false;
128  }
129  return new JsonResponse([
130  'success' => $success,
131  ]);
132  }
133 
139  public function ‪executeSilentTemplateFileUpdateAction(): ResponseInterface
140  {
141  $success = true;
142  try {
143  $this->silentTemplateFileUpgradeService->execute();
144  } catch (TemplateFileChangedException $e) {
145  $success = false;
146  }
147  return new JsonResponse([
148  'success' => $success,
149  ]);
150  }
151 
158  public function ‪executeSilentExtensionConfigurationSynchronizationAction(): ResponseInterface
159  {
160  $extensionConfiguration = new ExtensionConfiguration();
161  $extensionConfiguration->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions();
162  return new JsonResponse([
163  'success' => true,
164  ]);
165  }
166 }
‪TYPO3\CMS\Install\Controller\LayoutController\$silentTemplateFileUpgradeService
‪SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService
Definition: LayoutController.php:48
‪TYPO3\CMS\Core\Package\FailsafePackageManager
Definition: FailsafePackageManager.php:27
‪TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException
Definition: ConfigurationChangedException.php:26
‪TYPO3\CMS\Core\Information\Typo3Version
Definition: Typo3Version.php:21
‪TYPO3\CMS\Core\Configuration\ExtensionConfiguration
Definition: ExtensionConfiguration.php:47
‪TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService
Definition: SilentConfigurationUpgradeService.php:43
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentExtensionConfigurationSynchronizationAction
‪executeSilentExtensionConfigurationSynchronizationAction()
Definition: LayoutController.php:157
‪TYPO3\CMS\Install\Controller\LayoutController\$silentConfigurationUpgradeService
‪SilentConfigurationUpgradeService $silentConfigurationUpgradeService
Definition: LayoutController.php:47
‪TYPO3\CMS\Core\Page\ImportMap
Definition: ImportMap.php:33
‪TYPO3\CMS\Install\Controller\LayoutController\mainLayoutAction
‪mainLayoutAction(ServerRequestInterface $request)
Definition: LayoutController.php:105
‪TYPO3\CMS\Install\Controller\ControllerTrait
Definition: ControllerTrait.php:31
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentTemplateFileUpdateAction
‪ResponseInterface executeSilentTemplateFileUpdateAction()
Definition: LayoutController.php:138
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:160
‪TYPO3\CMS\Install\Controller\LayoutController\__construct
‪__construct(FailsafePackageManager $packageManager, SilentConfigurationUpgradeService $silentConfigurationUpgradeService, SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService)
Definition: LayoutController.php:50
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentConfigurationUpdateAction
‪ResponseInterface executeSilentConfigurationUpdateAction()
Definition: LayoutController.php:120
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:18
‪TYPO3\CMS\Core\Security\Nonce\create
‪static create(int $length=self::MIN_BYTES)
Definition: Nonce.php:37
‪TYPO3\CMS\Install\Service\SilentTemplateFileUpgradeService
Definition: SilentTemplateFileUpgradeService.php:35
‪TYPO3\CMS\Install\Service\Exception\TemplateFileChangedException
Definition: TemplateFileChangedException.php:26
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:584
‪TYPO3\CMS\Install\Controller\LayoutController
Definition: LayoutController.php:44
‪TYPO3\CMS\Install\Controller\AbstractController\initializeView
‪initializeView(ServerRequestInterface $request)
Definition: AbstractController.php:39
‪TYPO3\CMS\Core\Security\Nonce
Definition: Nonce.php:29
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:28
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Install\Controller\AbstractController
Definition: AbstractController.php:35
‪TYPO3\CMS\Install\Controller\LayoutController\initAction
‪initAction(ServerRequestInterface $request)
Definition: LayoutController.php:64
‪TYPO3\CMS\Install\Controller\LayoutController\$packageManager
‪FailsafePackageManager $packageManager
Definition: LayoutController.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static getContext()
Definition: Environment.php:128
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26