‪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;
38 
48 {
50 
51  public function ‪__construct(
52  private readonly ‪FailsafePackageManager $packageManager,
53  private readonly ‪SilentConfigurationUpgradeService $silentConfigurationUpgradeService,
54  private readonly ‪SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService,
55  private readonly ‪BackendEntryPointResolver $backendEntryPointResolver,
56  ) {}
57 
62  public function ‪initAction(ServerRequestInterface $request): ResponseInterface
63  {
64  $bust = ‪$GLOBALS['EXEC_TIME'];
65  if (!‪Environment::getContext()->isDevelopment()) {
67  }
68 
69  $packages = [
70  $this->packageManager->getPackage('core'),
71  $this->packageManager->getPackage('backend'),
72  $this->packageManager->getPackage('install'),
73  ];
74  $importMap = new ImportMap($packages);
75  $sitePath = $request->getAttribute('normalizedParams')->getSitePath();
76  $initModule = $sitePath . $importMap->resolveImport('@typo3/install/init-install.js');
77 
78  $view = $this->‪initializeView($request);
79  $nonce = new ConsumableNonce();
80  $view->assignMultiple([
81  // time is used as cache bust for js and css resources
82  'bust' => $bust,
83  'siteName' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
84  'initModule' => $initModule,
85  'importmap' => $importMap->render($sitePath, $nonce),
86  ]);
87  return new HtmlResponse(
88  $view->render('Layout/Init'),
89  200,
90  [
91  'Cache-Control' => 'no-cache, no-store',
92  'Content-Security-Policy' => $this->createContentSecurityPolicy()->compile($nonce),
93  'Pragma' => 'no-cache',
94  ]
95  );
96  }
97 
103  public function ‪mainLayoutAction(ServerRequestInterface $request): ResponseInterface
104  {
105  $view = $this->‪initializeView($request);
106  $view->assign('moduleName', 'tools_tools' . ($request->getQueryParams()['install']['module'] ?? 'layout'));
107  $view->assign('backendUrl', (string)$this->backendEntryPointResolver->getUriFromRequest($request));
108  return new JsonResponse([
109  'success' => true,
110  'html' => $view->render('Layout/MainLayout'),
111  ]);
112  }
113 
119  public function ‪executeSilentConfigurationUpdateAction(): ResponseInterface
120  {
121  $success = true;
122  try {
123  $this->silentConfigurationUpgradeService->execute();
124  } catch (ConfigurationChangedException) {
125  $success = false;
126  } catch (SettingsWriteException $e) {
127  throw new SilentConfigurationUpgradeReadonlyException(code: 1688462974, throwable: $e);
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\Core\Package\FailsafePackageManager
Definition: FailsafePackageManager.php:27
‪TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException
Definition: ConfigurationChangedException.php:25
‪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:157
‪TYPO3\CMS\Core\Configuration\Exception\SettingsWriteException
Definition: SettingsWriteException.php:25
‪TYPO3\CMS\Core\Security\ContentSecurityPolicy\ConsumableNonce
Definition: ConsumableNonce.php:24
‪TYPO3\CMS\Core\Page\ImportMap
Definition: ImportMap.php:34
‪TYPO3\CMS\Install\Controller\LayoutController\mainLayoutAction
‪mainLayoutAction(ServerRequestInterface $request)
Definition: LayoutController.php:102
‪TYPO3\CMS\Install\Controller\ControllerTrait
Definition: ControllerTrait.php:30
‪TYPO3\CMS\Install\Service\Exception\SilentConfigurationUpgradeReadonlyException
Definition: SilentConfigurationUpgradeReadonlyException.php:28
‪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\executeSilentConfigurationUpdateAction
‪ResponseInterface executeSilentConfigurationUpdateAction()
Definition: LayoutController.php:118
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:18
‪TYPO3\CMS\Install\Service\SilentTemplateFileUpgradeService
Definition: SilentTemplateFileUpgradeService.php:35
‪TYPO3\CMS\Install\Service\Exception\TemplateFileChangedException
Definition: TemplateFileChangedException.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility\hmac
‪static string hmac($input, $additionalSecret='')
Definition: GeneralUtility.php:474
‪TYPO3\CMS\Install\Controller\LayoutController\__construct
‪__construct(private readonly FailsafePackageManager $packageManager, private readonly SilentConfigurationUpgradeService $silentConfigurationUpgradeService, private readonly SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService, private readonly BackendEntryPointResolver $backendEntryPointResolver,)
Definition: LayoutController.php:50
‪TYPO3\CMS\Install\Controller\LayoutController
Definition: LayoutController.php:48
‪TYPO3\CMS\Install\Controller\AbstractController\initializeView
‪initializeView(ServerRequestInterface $request)
Definition: AbstractController.php:39
‪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:61
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Routing\BackendEntryPointResolver
Definition: BackendEntryPointResolver.php:29
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static getContext()
Definition: Environment.php:128
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:28