[!!!][TASK] Rewrite install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Classes / Controller / Action / Step / EnvironmentAndFolders.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\Controller\Action;
28
29 /**
30 * Very first install step:
31 * - Needs execution if typo3conf/LocalConfiguration.php does not exist
32 * - Renders system environment output
33 * - Creates folders like typo3temp, see FolderStructure/DefaultFactory for details
34 * - Creates typo3conf/LocalConfiguration.php from factory
35 */
36 class EnvironmentAndFolders extends Action\AbstractAction implements StepInterface {
37
38 /**
39 * Execute environment and folder step:
40 * - Create main folder structure
41 * - Create typo3conf/LocalConfiguration.php
42 *
43 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
44 */
45 public function execute() {
46 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
47 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
48 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
49 $structureFacade = $folderStructureFactory->getStructure();
50 $structureFixMessages = $structureFacade->fix();
51 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
52 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
53 $errorsFromStructure = $statusUtility->filterBySeverity($structureFixMessages, 'error');
54
55 // Proceed with creating LocalConfiguration.php only if folder creation did not throw errors
56 if (empty($errorsFromStructure)) {
57 /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
58 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
59 $configurationManager->createLocalConfigurationFromFactoryConfiguration();
60
61 // Create enable install tool file after typo3conf & LocalConfiguration were created
62 $installToolService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
63 $installToolService->createInstallToolEnableFile();
64 }
65
66 return $errorsFromStructure;
67 }
68
69 /**
70 * Step needs to be executed if LocalConfiguration file does not exist.
71 *
72 * @return boolean
73 */
74 public function needsExecution() {
75 if (@is_file(PATH_typo3conf . 'LocalConfiguration.php')) {
76 return FALSE;
77 } else {
78 return TRUE;
79 }
80 }
81
82 /**
83 * Render this step
84 *
85 * @return string
86 */
87 public function handle() {
88 $this->initialize();
89
90 /** @var \TYPO3\CMS\Install\SystemEnvironment\Check $statusCheck */
91 $statusCheck = $this->objectManager->get('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
92 $statusObjects = $statusCheck->getStatus();
93 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
94 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
95 $environmentStatus = $statusUtility->sortBySeverity($statusObjects);
96 $this->view->assign('environmentStatus', $environmentStatus);
97
98 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
99 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
100 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
101 $structureFacade = $folderStructureFactory->getStructure();
102 $structureMessages = $structureFacade->getStatus();
103 /** @var $statusUtility \TYPO3\CMS\Install\Status\StatusUtility */
104 $structureErrors = $statusUtility->filterBySeverity($structureMessages, 'error');
105 $this->view->assign('structureErrors', $structureErrors);
106
107 if (count($environmentStatus['error']) > 0
108 || count($environmentStatus['warning']) > 0
109 || count($structureErrors) > 0
110 ) {
111 $this->view->assign('errorsOrWarningsFromStatus', TRUE);
112 }
113
114 return $this->view->render();
115 }
116 }
117 ?>