|
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
|
|
|
|
|
18
|
|
|
namespace TYPO3\CMS\Install\Controller; |
|
19
|
|
|
|
|
20
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
21
|
|
|
use Psr\Http\Message\ServerRequestInterface; |
|
22
|
|
|
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration; |
|
23
|
|
|
use TYPO3\CMS\Core\Core\Environment; |
|
24
|
|
|
use TYPO3\CMS\Core\Http\HtmlResponse; |
|
25
|
|
|
use TYPO3\CMS\Core\Http\JsonResponse; |
|
26
|
|
|
use TYPO3\CMS\Core\Information\Typo3Version; |
|
27
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
28
|
|
|
use TYPO3\CMS\Install\Service\Exception\ConfigurationChangedException; |
|
29
|
|
|
use TYPO3\CMS\Install\Service\Exception\TemplateFileChangedException; |
|
30
|
|
|
use TYPO3\CMS\Install\Service\SilentConfigurationUpgradeService; |
|
31
|
|
|
use TYPO3\CMS\Install\Service\SilentTemplateFileUpgradeService; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* Layout controller |
|
35
|
|
|
* |
|
36
|
|
|
* Renders a first "load the Javascript in <head>" view, and the |
|
37
|
|
|
* main layout of the install tool in second action. |
|
38
|
|
|
* @internal This class is a specific controller implementation and is not considered part of the Public TYPO3 API. |
|
39
|
|
|
*/ |
|
40
|
|
|
class LayoutController extends AbstractController |
|
41
|
|
|
{ |
|
42
|
|
|
private SilentConfigurationUpgradeService $silentConfigurationUpgradeService; |
|
43
|
|
|
private SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService; |
|
44
|
|
|
|
|
45
|
|
|
public function __construct( |
|
46
|
|
|
SilentConfigurationUpgradeService $silentConfigurationUpgradeService, |
|
47
|
|
|
SilentTemplateFileUpgradeService $silentTemplateFileUpgradeService |
|
48
|
|
|
) { |
|
49
|
|
|
$this->silentConfigurationUpgradeService = $silentConfigurationUpgradeService; |
|
50
|
|
|
$this->silentTemplateFileUpgradeService = $silentTemplateFileUpgradeService; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* The init action renders an HTML response with HTML view having <head> section |
|
55
|
|
|
* containing resources to main .js routing. |
|
56
|
|
|
* |
|
57
|
|
|
* @param ServerRequestInterface $request |
|
58
|
|
|
* @return ResponseInterface |
|
59
|
|
|
*/ |
|
60
|
|
|
public function initAction(ServerRequestInterface $request): ResponseInterface |
|
61
|
|
|
{ |
|
62
|
|
|
$bust = $GLOBALS['EXEC_TIME']; |
|
63
|
|
|
if (!Environment::getContext()->isDevelopment()) { |
|
64
|
|
|
$bust = GeneralUtility::hmac((string)(new Typo3Version()) . Environment::getProjectPath()); |
|
65
|
|
|
} |
|
66
|
|
|
$view = $this->initializeStandaloneView($request, 'Layout/Init.html'); |
|
67
|
|
|
$view->assignMultiple([ |
|
68
|
|
|
// time is used as cache bust for js and css resources |
|
69
|
|
|
'bust' => $bust, |
|
70
|
|
|
'siteName' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], |
|
71
|
|
|
]); |
|
72
|
|
|
return new HtmlResponse( |
|
73
|
|
|
$view->render(), |
|
74
|
|
|
200, |
|
75
|
|
|
[ |
|
76
|
|
|
'Cache-Control' => 'no-cache, must-revalidate', |
|
77
|
|
|
'Pragma' => 'no-cache' |
|
78
|
|
|
] |
|
79
|
|
|
); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Return a json response with the main HTML layout body: Toolbar, main menu and |
|
84
|
|
|
* doc header in standalone, doc header only in backend context. Silent updaters |
|
85
|
|
|
* are executed before this main view is loaded. |
|
86
|
|
|
* |
|
87
|
|
|
* @param ServerRequestInterface $request |
|
88
|
|
|
* @return ResponseInterface |
|
89
|
|
|
*/ |
|
90
|
|
|
public function mainLayoutAction(ServerRequestInterface $request): ResponseInterface |
|
91
|
|
|
{ |
|
92
|
|
|
$view = $this->initializeStandaloneView($request, 'Layout/MainLayout.html'); |
|
93
|
|
|
return new JsonResponse([ |
|
94
|
|
|
'success' => true, |
|
95
|
|
|
'html' => $view->render(), |
|
96
|
|
|
]); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Execute silent configuration update. May be called multiple times until success = true is returned. |
|
101
|
|
|
* |
|
102
|
|
|
* @return ResponseInterface success = true if no change has been done |
|
103
|
|
|
*/ |
|
104
|
|
|
public function executeSilentConfigurationUpdateAction(): ResponseInterface |
|
105
|
|
|
{ |
|
106
|
|
|
$success = true; |
|
107
|
|
|
try { |
|
108
|
|
|
$this->silentConfigurationUpgradeService->execute(); |
|
109
|
|
|
} catch (ConfigurationChangedException $e) { |
|
110
|
|
|
$success = false; |
|
111
|
|
|
} |
|
112
|
|
|
return new JsonResponse([ |
|
113
|
|
|
'success' => $success, |
|
114
|
|
|
]); |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* Execute silent template files update. May be called multiple times until success = true is returned. |
|
119
|
|
|
* |
|
120
|
|
|
* @return ResponseInterface success = true if no change has been done |
|
121
|
|
|
*/ |
|
122
|
|
|
public function executeSilentTemplateFileUpdateAction(): ResponseInterface |
|
123
|
|
|
{ |
|
124
|
|
|
$success = true; |
|
125
|
|
|
try { |
|
126
|
|
|
$this->silentTemplateFileUpgradeService->execute(); |
|
127
|
|
|
} catch (TemplateFileChangedException $e) { |
|
128
|
|
|
$success = false; |
|
129
|
|
|
} |
|
130
|
|
|
return new JsonResponse([ |
|
131
|
|
|
'success' => $success, |
|
132
|
|
|
]); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
/** |
|
136
|
|
|
* Synchronize TYPO3_CONF_VARS['EXTENSIONS'] with possibly new defaults from extensions |
|
137
|
|
|
* ext_conf_template.txt files. This make LocalConfiguration the only source of truth for |
|
138
|
|
|
* extension configuration and it is always up to date, also if an extension has been |
|
139
|
|
|
* updated. |
|
140
|
|
|
* |
|
141
|
|
|
* @return ResponseInterface |
|
142
|
|
|
*/ |
|
143
|
|
|
public function executeSilentExtensionConfigurationSynchronizationAction(): ResponseInterface |
|
144
|
|
|
{ |
|
145
|
|
|
$extensionConfiguration = new ExtensionConfiguration(); |
|
146
|
|
|
$extensionConfiguration->synchronizeExtConfTemplateWithLocalConfigurationOfAllExtensions(); |
|
147
|
|
|
return new JsonResponse([ |
|
148
|
|
|
'success' => true, |
|
149
|
|
|
]); |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|