[TASK] Use fully qualified name resolution in PHP 5.5
[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 * 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 /**
18 * Very first install step:
19 * - Needs execution if typo3conf/LocalConfiguration.php does not exist
20 * - Renders system environment output
21 * - Creates folders like typo3temp, see FolderStructure/DefaultFactory for details
22 * - Creates typo3conf/LocalConfiguration.php from factory
23 */
24 class EnvironmentAndFolders extends AbstractStepAction {
25
26 /**
27 * Execute environment and folder step:
28 * - Create main folder structure
29 * - Create typo3conf/LocalConfiguration.php
30 *
31 * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
32 */
33 public function execute() {
34 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
35 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
36 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
37 $structureFacade = $folderStructureFactory->getStructure();
38 $structureFixMessages = $structureFacade->fix();
39 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
40 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
41 $errorsFromStructure = $statusUtility->filterBySeverity($structureFixMessages, 'error');
42
43 if (@is_dir(PATH_typo3conf)) {
44 /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
45 $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
46 $configurationManager->createLocalConfigurationFromFactoryConfiguration();
47
48 // Create a PackageStates.php with all packages activated marked as "part of factory default"
49 if (!file_exists(PATH_typo3conf . 'PackageStates.php')) {
50 /** @var \TYPO3\CMS\Core\Package\FailsafePackageManager $packageManager */
51 $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getEarlyInstance('TYPO3\\Flow\\Package\\PackageManager');
52 $packages = $packageManager->getAvailablePackages();
53 foreach ($packages as $package) {
54 /** @var $package \TYPO3\CMS\Core\Package\PackageInterface */
55 if ($package instanceof \TYPO3\CMS\Core\Package\PackageInterface
56 && $package->isPartOfFactoryDefault()
57 ) {
58 $packageManager->activatePackage($package->getPackageKey());
59 }
60 }
61 $packageManager->forceSortAndSavePackageStates();
62 }
63
64 // Create enable install tool file after typo3conf & LocalConfiguration were created
65 /** @var \TYPO3\CMS\Install\Service\EnableFileService $installToolService */
66 $installToolService = $this->objectManager->get('TYPO3\\CMS\\Install\\Service\\EnableFileService');
67 $installToolService->removeFirstInstallFile();
68 $installToolService->createInstallToolEnableFile();
69 }
70
71 return $errorsFromStructure;
72 }
73
74 /**
75 * Step needs to be executed if LocalConfiguration file does not exist.
76 *
77 * @return bool
78 */
79 public function needsExecution() {
80 if (@is_file(PATH_typo3conf . 'LocalConfiguration.php')) {
81 return FALSE;
82 } else {
83 return TRUE;
84 }
85 }
86
87 /**
88 * Executes the step
89 *
90 * @return string Rendered content
91 */
92 protected function executeAction() {
93 /** @var \TYPO3\CMS\Install\SystemEnvironment\Check $statusCheck */
94 $statusCheck = $this->objectManager->get('TYPO3\\CMS\\Install\\SystemEnvironment\\Check');
95 $statusObjects = $statusCheck->getStatus();
96 /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
97 $statusUtility = $this->objectManager->get('TYPO3\\CMS\\Install\\Status\\StatusUtility');
98 $environmentStatus = $statusUtility->sortBySeverity($statusObjects);
99 $alerts = $statusUtility->filterBySeverity($statusObjects, 'alert');
100 $this->view->assign('alerts', $alerts);
101 $this->view->assign('environmentStatus', $environmentStatus);
102
103 /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
104 $folderStructureFactory = $this->objectManager->get('TYPO3\\CMS\\Install\\FolderStructure\\DefaultFactory');
105 /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
106 $structureFacade = $folderStructureFactory->getStructure();
107 $structureMessages = $structureFacade->getStatus();
108 /** @var $statusUtility \TYPO3\CMS\Install\Status\StatusUtility */
109 $structureErrors = $statusUtility->filterBySeverity($structureMessages, 'error');
110 $this->view->assign('structureErrors', $structureErrors);
111
112 if (count($environmentStatus['error']) > 0
113 || count($environmentStatus['warning']) > 0
114 || count($structureErrors) > 0
115 ) {
116 $this->view->assign('errorsOrWarningsFromStatus', TRUE);
117 }
118 $this->assignSteps();
119
120 return $this->view->render(!empty($alerts));
121 }
122 }