‪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;
37 
47 {
49 
50  public function ‪__construct(
51  private readonly ‪FailsafePackageManager $packageManager,
52  private readonly ‪SilentConfigurationUpgradeService $silentConfigurationUpgradeService,
53  private readonly ‪SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService
54  ) {
55  }
56 
61  public function ‪initAction(ServerRequestInterface $request): ResponseInterface
62  {
63  $bust = ‪$GLOBALS['EXEC_TIME'];
64  if (!‪Environment::getContext()->isDevelopment()) {
66  }
67 
68  $packages = [
69  $this->packageManager->getPackage('core'),
70  $this->packageManager->getPackage('backend'),
71  $this->packageManager->getPackage('install'),
72  ];
73  $importMap = new ImportMap($packages);
74  $sitePath = $request->getAttribute('normalizedParams')->getSitePath();
75  $initModule = $sitePath . $importMap->resolveImport('@typo3/install/init-install.js');
76 
77  $view = $this->‪initializeView($request);
78  $nonce = ‪Nonce::create();
79  $view->assignMultiple([
80  // time is used as cache bust for js and css resources
81  'bust' => $bust,
82  'siteName' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
83  'initModule' => $initModule,
84  'importmap' => $importMap->render($sitePath, $nonce->b64),
85  ]);
86  return new HtmlResponse(
87  $view->render('Layout/Init'),
88  200,
89  [
90  'Cache-Control' => 'no-cache, must-revalidate',
91  'Content-Security-Policy' => $this->createContentSecurityPolicy()->compile($nonce),
92  'Pragma' => 'no-cache',
93  ]
94  );
95  }
96 
102  public function ‪mainLayoutAction(ServerRequestInterface $request): ResponseInterface
103  {
104  $view = $this->‪initializeView($request);
105  $view->assign('moduleName', 'tools_tools' . ($request->getQueryParams()['install']['module'] ?? 'layout'));
106  return new JsonResponse([
107  'success' => true,
108  'html' => $view->render('Layout/MainLayout'),
109  ]);
110  }
111 
117  public function ‪executeSilentConfigurationUpdateAction(): ResponseInterface
118  {
119  $success = true;
120  try {
121  $this->silentConfigurationUpgradeService->execute();
122  } catch (ConfigurationChangedException) {
123  $success = false;
124  } catch (SettingsWriteException $e) {
125  throw new SilentConfigurationUpgradeReadonlyException(code: 1688462974, throwable: $e);
126  }
127  return new JsonResponse([
128  'success' => $success,
129  ]);
130  }
131 
137  public function ‪executeSilentTemplateFileUpdateAction(): ResponseInterface
138  {
139  $success = true;
140  try {
141  $this->silentTemplateFileUpgradeService->execute();
142  } catch (TemplateFileChangedException $e) {
143  $success = false;
144  }
145  return new JsonResponse([
146  'success' => $success,
147  ]);
148  }
149 
156  public function ‪executeSilentExtensionConfigurationSynchronizationAction(): ResponseInterface
157  {
158  $extensionConfiguration = new ExtensionConfiguration();
159  $extensionConfiguration->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions();
160  return new JsonResponse([
161  'success' => true,
162  ]);
163  }
164 }
‪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:45
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentExtensionConfigurationSynchronizationAction
‪executeSilentExtensionConfigurationSynchronizationAction()
Definition: LayoutController.php:155
‪TYPO3\CMS\Core\Configuration\Exception\SettingsWriteException
Definition: SettingsWriteException.php:26
‪TYPO3\CMS\Core\Page\ImportMap
Definition: ImportMap.php:34
‪TYPO3\CMS\Install\Controller\LayoutController\mainLayoutAction
‪mainLayoutAction(ServerRequestInterface $request)
Definition: LayoutController.php:101
‪TYPO3\CMS\Install\Controller\ControllerTrait
Definition: ControllerTrait.php:30
‪TYPO3\CMS\Install\Service\Exception\SilentConfigurationUpgradeReadonlyException
Definition: SilentConfigurationUpgradeReadonlyException.php:28
‪TYPO3\CMS\Install\Controller\LayoutController\__construct
‪__construct(private readonly FailsafePackageManager $packageManager, private readonly SilentConfigurationUpgradeService $silentConfigurationUpgradeService, private readonly SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService)
Definition: LayoutController.php:49
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentTemplateFileUpdateAction
‪ResponseInterface executeSilentTemplateFileUpdateAction()
Definition: LayoutController.php:136
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:160
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentConfigurationUpdateAction
‪ResponseInterface executeSilentConfigurationUpdateAction()
Definition: LayoutController.php:116
‪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:475
‪TYPO3\CMS\Install\Controller\LayoutController
Definition: LayoutController.php:47
‪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:60
‪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:28