[!!!][TASK] Remove deprecated code from EXT:install
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / LayoutController.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Install\Controller;
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\ExtensionConfiguration;
21 use TYPO3\CMS\Core\Http\HtmlResponse;
22 use TYPO3\CMS\Core\Http\JsonResponse;
23 use TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException;
24 use TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService;
25
26 /**
27 * Layout controller
28 *
29 * Renders a first "load the Javascript in <head>" view, and the
30 * main layout of the install tool in second action.
31 * @internal This class is a specific controller implementation and is not considered part of the Public TYPO3 API.
32 */
33 class LayoutController extends AbstractController
34 {
35 /**
36 * The init action renders an HTML response with HTML view having <head> section
37 * containing resources to main .js routing.
38 *
39 * @param ServerRequestInterface $request
40 * @return ResponseInterface
41 */
42 public function initAction(ServerRequestInterface $request): ResponseInterface
43 {
44 $view = $this->initializeStandaloneView($request, 'Layout/Init.html');
45 $view->assignMultiple([
46 // time is used as cache bust for js and css resources
47 'time' => time(),
48 'siteName' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'],
49 ]);
50 return new HtmlResponse(
51 $view->render(),
52 200,
53 [
54 'Cache-Control' => 'no-cache, must-revalidate',
55 'Pragma' => 'no-cache'
56 ]
57 );
58 }
59
60 /**
61 * Return a json response with the main HTML layout body: Toolbar, main menu and
62 * doc header in standalone, doc header only in backend context. Silent updaters
63 * are executed before this main view is loaded.
64 *
65 * @param ServerRequestInterface $request
66 * @return ResponseInterface
67 */
68 public function mainLayoutAction(ServerRequestInterface $request): ResponseInterface
69 {
70 $view = $this->initializeStandaloneView($request, 'Layout/MainLayout.html');
71 return new JsonResponse([
72 'success' => true,
73 'html' => $view->render(),
74 ]);
75 }
76
77 /**
78 * Execute silent configuration update. May be called multiple times until success = true is returned.
79 *
80 * @return ResponseInterface success = true if no change has been done
81 */
82 public function executeSilentConfigurationUpdateAction(): ResponseInterface
83 {
84 $silentUpdate = new SilentConfigurationUpgradeService();
85 $success = true;
86 try {
87 $silentUpdate->execute();
88 } catch (ConfigurationChangedException $e) {
89 $success = false;
90 }
91 return new JsonResponse([
92 'success' => $success,
93 ]);
94 }
95
96 /**
97 * Synchronize TYPO3_CONF_VARS['EXTENSIONS'] with possibly new defaults from extensions
98 * ext_conf_template.txt files. This make LocalConfiguration the only source of truth for
99 * extension configuration and it is always up to date, also if an extension has been
100 * updated.
101 *
102 * @return ResponseInterface
103 */
104 public function executeSilentExtensionConfigurationSynchronizationAction(): ResponseInterface
105 {
106 $extensionConfiguration = new ExtensionConfiguration();
107 $extensionConfiguration->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions();
108 return new JsonResponse([
109 'success' => true,
110 ]);
111 }
112 }