[TASK] Refactor install tool enable file checks
[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 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 use TYPO3\CMS\Install\Service\EnableFileService;
28
29 /**
30 * Set production defaults
31 */
32 class DefaultConfiguration extends AbstractStepAction {
33
34 /**
35 * Set defaults of auto configuration, mark installation as completed
36 *
37 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
38 */
39 public function execute() {
40 /** @var \TYPO3\CMS\Install\Configuration\FeatureManager $featureManager */
41 $featureManager = $this->objectManager->get('TYPO3\\CMS\\Install\\Configuration\\FeatureManager');
42 // Get best matching configuration presets
43 $configurationValues = $featureManager->getBestMatchingConfigurationForAllFeatures();
44
45 // let the admin user redirect to the distributions page on first login
46 if (isset($this->postValues['values']['loaddistributions'])) {
47
48 // update the admin backend user to show the distribution management on login
49 $adminUserFirstLogin = array('startModuleOnFirstLogin' => 'tools_ExtensionmanagerExtensionmanager->tx_extensionmanager_tools_extensionmanagerextensionmanager%5Baction%5D=distributions&tx_extensionmanager_tools_extensionmanagerextensionmanager%5Bcontroller%5D=List');
50 $this->getDatabaseConnection()->exec_UPDATEquery(
51 'be_users',
52 'admin=1',
53 array('uc' => serialize($adminUserFirstLogin))
54 );
55 }
56
57 // Setting SYS/isInitialInstallationInProgress to FALSE marks this instance installation as complete
58 $configurationValues['SYS/isInitialInstallationInProgress'] = FALSE;
59
60 /** @var $configurationManager \TYPO3\CMS\Core\Configuration\ConfigurationManager */
61 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
62 $configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
63
64 /** @var \TYPO3\CMS\Install\Service\SessionService $session */
65 $session = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\SessionService');
66 $session->destroySession();
67
68 /** @var $formProtection \TYPO3\CMS\Core\FormProtection\InstallToolFormProtection */
69 $formProtection = \TYPO3\CMS\Core\FormProtection\FormProtectionFactory::get(
70 'TYPO3\\CMS\\Core\\FormProtection\\InstallToolFormProtection'
71 );
72 $formProtection->clean();
73
74 if (!EnableFileService::isInstallToolEnableFilePermanent()) {
75 EnableFileService::removeInstallToolEnableFile();
76 }
77
78 \TYPO3\CMS\Core\Utility\HttpUtility::redirect('../../../index.php', \TYPO3\CMS\Core\Utility\HttpUtility::HTTP_STATUS_303);
79 }
80
81 /**
82 * Step needs to be executed if 'isInitialInstallationInProgress' is set to TRUE in LocalConfiguration
83 *
84 * @return boolean
85 */
86 public function needsExecution() {
87 $result = FALSE;
88 if (isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'])
89 && $GLOBALS['TYPO3_CONF_VARS']['SYS']['isInitialInstallationInProgress'] === TRUE
90 ) {
91 $result = TRUE;
92 }
93 return $result;
94 }
95
96 /**
97 * Executes the step
98 *
99 * @return string Rendered content
100 */
101 protected function executeAction() {
102 return $this->view->render();
103 }
104 }