[BUGFIX] ext:install Better error handling in first folder step
[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 if (@is_dir(PATH_typo3conf)) {
56 /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
57 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
58 $configurationManager->createLocalConfigurationFromFactoryConfiguration();
59
60 // Create enable install tool file after typo3conf & LocalConfiguration were created
61 $installToolService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
62 $installToolService->createInstallToolEnableFile();
63 }
64
65 return $errorsFromStructure;
66 }
67
68 /**
69 * Step needs to be executed if LocalConfiguration file does not exist.
70 *
71 * @return boolean
72 */
73 public function needsExecution() {
74 if (@is_file(PATH_typo3conf . 'LocalConfiguration.php')) {
75 return FALSE;
76 } else {
77 return TRUE;
78 }
79 }
80
81 /**
82 * Render this step
83 *
84 * @return string
85 */
86 public function handle() {
87 $this->initializeHandle();
88
89 /** @var \TYPO3\CMS\Install\SystemEnvironment\Check $statusCheck */
90 $statusCheck = $this->objectManager->get('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
91 $statusObjects = $statusCheck->getStatus();
92 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
93 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
94 $environmentStatus = $statusUtility->sortBySeverity($statusObjects);
95 $this->view->assign('environmentStatus', $environmentStatus);
96
97 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
98 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
99 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
100 $structureFacade = $folderStructureFactory->getStructure();
101 $structureMessages = $structureFacade->getStatus();
102 /** @var $statusUtility \TYPO3\CMS\Install\Status\StatusUtility */
103 $structureErrors = $statusUtility->filterBySeverity($structureMessages, 'error');
104 $this->view->assign('structureErrors', $structureErrors);
105
106 if (count($environmentStatus['error']) > 0
107 || count($environmentStatus['warning']) > 0
108 || count($structureErrors) > 0
109 ) {
110 $this->view->assign('errorsOrWarningsFromStatus', TRUE);
111 }
112
113 return $this->view->render();
114 }
115 }
116 ?>