‪TYPO3CMS  9.5
LayoutController.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Psr\Http\Message\ResponseInterface;
19 use Psr\Http\Message\ServerRequestInterface;
20 use TYPO3\CMS\Core\Configuration\ConfigurationManager;
27 
36 {
44  public function ‪initAction(ServerRequestInterface $request): ResponseInterface
45  {
46  $view = $this->‪initializeStandaloneView($request, 'Layout/Init.html');
47  $view->assignMultiple([
48  // time is used as cache bust for js and css resources
49  'time' => time(),
50  'siteName' => ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
51  ]);
52  return new ‪HtmlResponse(
53  $view->render(),
54  200,
55  [
56  'Cache-Control' => 'no-cache, must-revalidate',
57  'Pragma' => 'no-cache'
58  ]
59  );
60  }
61 
70  public function ‪mainLayoutAction(ServerRequestInterface $request): ResponseInterface
71  {
72  $view = $this->‪initializeStandaloneView($request, 'Layout/MainLayout.html');
73  return new ‪JsonResponse([
74  'success' => true,
75  'html' => $view->render(),
76  ]);
77  }
78 
84  public function ‪executeSilentConfigurationUpdateAction(): ResponseInterface
85  {
86  $silentUpdate = new ‪SilentConfigurationUpgradeService();
87  $success = true;
88  try {
89  $silentUpdate->execute();
91  $success = false;
92  }
93  return new ‪JsonResponse([
94  'success' => $success,
95  ]);
96  }
97 
107  {
108  $configurationManager = new ConfigurationManager();
109  try {
110  $oldExtConfSettings = $configurationManager->getConfigurationValueByPath('EXT/extConf');
111  } catch (‪MissingArrayPathException $e) {
112  // The old 'extConf' array may not exist anymore, set to empty array if so.
113  $oldExtConfSettings = [];
114  }
115  try {
116  $newExtensionSettings = $configurationManager->getConfigurationValueByPath('EXTENSIONS');
117  } catch (‪MissingArrayPathException $e) {
118  // New 'EXTENSIONS' array may not exist yet, for instance if just upgrading to v9
119  $newExtensionSettings = [];
120  }
121  foreach ($oldExtConfSettings as $extensionName => $extensionSettings) {
122  if (!array_key_exists($extensionName, $newExtensionSettings)) {
123  $unserializedConfiguration = unserialize($extensionSettings, ['allowed_classes' => false]);
124  if (is_array($unserializedConfiguration)) {
125  $newExtensionSettings = $this->‪removeDotsFromArrayKeysRecursive($unserializedConfiguration);
126  $configurationManager->setLocalConfigurationValueByPath('EXTENSIONS/' . $extensionName, $newExtensionSettings);
127  }
128  }
129  }
130  return new ‪JsonResponse([
131  'success' => true,
132  ]);
133  }
134 
144  {
145  $extensionConfiguration = new ‪ExtensionConfiguration();
146  $extensionConfiguration->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions();
147  return new ‪JsonResponse([
148  'success' => true,
149  ]);
150  }
151 
162  private function ‪removeDotsFromArrayKeysRecursive(array $settings): array
163  {
164  $settingsWithoutDots = [];
165  foreach ($settings as $key => $value) {
166  if (is_array($value)) {
167  $settingsWithoutDots[rtrim($key, '.')] = $this->‪removeDotsFromArrayKeysRecursive($value);
168  } else {
169  $settingsWithoutDots[$key] = $value;
170  }
171  }
172  return $settingsWithoutDots;
173  }
174 }
‪TYPO3\CMS\Install\Controller\LayoutController\initAction
‪ResponseInterface initAction(ServerRequestInterface $request)
Definition: LayoutController.php:44
‪TYPO3\CMS\Install\Controller\AbstractController\initializeStandaloneView
‪StandaloneView initializeStandaloneView(ServerRequestInterface $request, string $templatePath)
Definition: AbstractController.php:37
‪TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException
Definition: ConfigurationChangedException.php:24
‪TYPO3\CMS\Core\Configuration\ExtensionConfiguration
Definition: ExtensionConfiguration.php:42
‪TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService
Definition: SilentConfigurationUpgradeService.php:42
‪TYPO3\CMS\Core\Utility\Exception\MissingArrayPathException
Definition: MissingArrayPathException.php:26
‪TYPO3\CMS\Install\Controller\LayoutController\removeDotsFromArrayKeysRecursive
‪array removeDotsFromArrayKeysRecursive(array $settings)
Definition: LayoutController.php:162
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentLegacyExtConfExtensionConfigurationUpdateAction
‪ResponseInterface executeSilentLegacyExtConfExtensionConfigurationUpdateAction()
Definition: LayoutController.php:106
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentConfigurationUpdateAction
‪ResponseInterface executeSilentConfigurationUpdateAction()
Definition: LayoutController.php:84
‪TYPO3\CMS\Install\Controller
Definition: AbstractController.php:3
‪TYPO3\CMS\Install\Controller\LayoutController\mainLayoutAction
‪ResponseInterface mainLayoutAction(ServerRequestInterface $request)
Definition: LayoutController.php:70
‪TYPO3\CMS\Install\Controller\LayoutController
Definition: LayoutController.php:36
‪TYPO3\CMS\Install\Controller\LayoutController\executeSilentExtensionConfigurationSynchronizationAction
‪ResponseInterface executeSilentExtensionConfigurationSynchronizationAction()
Definition: LayoutController.php:143
‪TYPO3\CMS\Core\Http\JsonResponse
Definition: JsonResponse.php:25
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Install\Controller\AbstractController
Definition: AbstractController.php:28
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:25