‪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  private readonly ‪HashService $hashService,
57  ) {}
58 
63  public function ‪initAction(ServerRequestInterface $request): ResponseInterface
64  {
65  $bust = ‪$GLOBALS['EXEC_TIME'];
66  if (!‪Environment::getContext()->isDevelopment()) {
67  $bust = $this->hashService->hmac((new ‪Typo3Version()) . ‪Environment::getProjectPath(), self::class);
68  }
69 
70  $packages = [
71  $this->packageManager->getPackage('core'),
72  $this->packageManager->getPackage('backend'),
73  $this->packageManager->getPackage('install'),
74  ];
75  $importMap = new ImportMap($this->hashService, $packages);
76  $sitePath = $request->getAttribute('normalizedParams')->getSitePath();
77  $initModule = $sitePath . $importMap->resolveImport('@typo3/install/init-install.js');
78 
79  $view = $this->‪initializeView($request);
80  $nonce = new ConsumableNonce();
81  $view->assignMultiple([
82  // time is used as cache bust for js and css resources
83  'bust' => $bust,
84  'siteName' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
85  'initModule' => $initModule,
86  'importmap' => $importMap->render($sitePath, $nonce),
87  ]);
88  return new HtmlResponse(
89  $view->render('Layout/Init'),
90  200,
91  [
92  'Cache-Control' => 'no-cache, no-store',
93  'Content-Security-Policy' => $this->createContentSecurityPolicy()->compile($nonce),
94  'Pragma' => 'no-cache',
95  ]
96  );
97  }
98 
104  public function ‪mainLayoutAction(ServerRequestInterface $request): ResponseInterface
105  {
106  $view = $this->‪initializeView($request);
107  $view->assign('moduleName', 'tools_tools' . ($request->getQueryParams()['install']['module'] ?? 'layout'));
108  $view->assign('backendUrl', (string)$this->backendEntryPointResolver->getUriFromRequest($request));
109  return new JsonResponse([
110  'success' => true,
111  'html' => $view->render('Layout/MainLayout'),
112  ]);
113  }
114 
120  public function ‪executeSilentConfigurationUpdateAction(): ResponseInterface
121  {
122  $success = true;
123  try {
124  $this->silentConfigurationUpgradeService->execute();
125  } catch (ConfigurationChangedException) {
126  $success = false;
127  } catch (SettingsWriteException $e) {
128  throw new SilentConfigurationUpgradeReadonlyException(code: 1688462974, throwable: $e);
129  }
130  return new JsonResponse([
131  'success' => $success,
132  ]);
133  }
134 
140  public function ‪executeSilentTemplateFileUpdateAction(): ResponseInterface
141  {
142  $success = true;
143  try {
144  $this->silentTemplateFileUpgradeService->execute();
145  } catch (TemplateFileChangedException $e) {
146  $success = false;
147  }
148  return new JsonResponse([
149  'success' => $success,
150  ]);
151  }
152 
159  public function ‪executeSilentExtensionConfigurationSynchronizationAction(): ResponseInterface
160  {
161  $extensionConfiguration = new ExtensionConfiguration();
162  $extensionConfiguration->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions();
163  return new JsonResponse([
164  'success' => true,
165  ]);
166  }
167 }
‪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:158
‪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:35
‪TYPO3\CMS\Install\Controller\LayoutController\mainLayoutAction
‪mainLayoutAction(ServerRequestInterface $request)
Definition: LayoutController.php:103
‪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:139
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:160
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentConfigurationUpdateAction
‪ResponseInterface executeSilentConfigurationUpdateAction()
Definition: LayoutController.php:119
‪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\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:62
‪TYPO3\CMS\Install\Controller\LayoutController\__construct
‪__construct(private readonly FailsafePackageManager $packageManager, private readonly SilentConfigurationUpgradeService $silentConfigurationUpgradeService, private readonly SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService, private readonly BackendEntryPointResolver $backendEntryPointResolver, private readonly HashService $hashService,)
Definition: LayoutController.php:50
‪TYPO3\CMS\Core\Crypto\HashService
Definition: HashService.php:27
‪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