00d69abed76d6ee2964c79d459e8f60a4a70c41a
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / DefaultConfiguration.php
1 <?php
2 namespace TYPO3\CMS\Install\Controller\Action\Step;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Install\Service\EnableFileService;
18
19 /**
20 * Set production defaults
21 */
22 class DefaultConfiguration extends AbstractStepAction
23 {
24 /**
25 * Set defaults of auto configuration, mark installation as completed
26 *
27 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
28 */
29 public function execute()
30 {
31 /** @var \TYPO3\CMS\Install\Configuration\FeatureManager $featureManager */
32 $featureManager = $this->objectManager->get(\TYPO3\CMS\Install\Configuration\FeatureManager::class);
33 // Get best matching configuration presets
34 $configurationValues = $featureManager->getBestMatchingConfigurationForAllFeatures();
35
36 // let the admin user redirect to the distributions page on first login
37 if (isset($this->postValues['values']['loaddistributions'])) {
38
39 // update the admin backend user to show the distribution management on login
40 $adminUserFirstLogin = array(
41 'startModuleOnFirstLogin' => 'tools_ExtensionmanagerExtensionmanager->tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=distributions&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List',
42 'ucSetByInstallTool' => '1',
43 );
44 $this->getDatabaseConnection()->exec_UPDATEquery(
45 'be_users',
46 'admin=1',
47 array('uc' => serialize($adminUserFirstLogin))
48 );
49 }
50
51 // Setting SYS/isInitialInstallationInProgress to FALSE marks this instance installation as complete
52 $configurationValues['SYS/isInitialInstallationInProgress'] = false;
53
54 // Mark upgrade wizards as done
55 $this->loadExtLocalconfDatabaseAndExtTables();
56 if (!empty($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'])) {
57 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/install']['update'] as $updateClassName) {
58 $configurationValues['INSTALL/wizardDone/' . $updateClassName] = 1;
59 }
60 }
61
62 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
63 $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
64 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
65
66 /** @var \TYPO3\CMS\Install\Service\SessionService $session */
67 $session = $this->objectManager->get(\TYPO3\CMS\Install\Service\SessionService::class);
68 $session->destroySession();
69
70 /** @var $formProtection \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection */
71 $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get(
72 \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection::class
73 );
74 $formProtection->clean();
75
76 if (!EnableFileService::isInstallToolEnableFilePermanent()) {
77 EnableFileService::removeInstallToolEnableFile();
78 }
79
80 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('../../../index.php', \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
81 }
82
83 /**
84 * Step needs to be executed if 'isInitialInstallationInProgress' is set to TRUE in LocalConfiguration
85 *
86 * @return bool
87 */
88 public function needsExecution()
89 {
90 $result = false;
91 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'])
92 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'] === true
93 ) {
94 $result = true;
95 }
96 return $result;
97 }
98
99 /**
100 * Executes the step
101 *
102 * @return string Rendered content
103 */
104 protected function executeAction()
105 {
106 $this->assignSteps();
107 return $this->view->render();
108 }
109 }