TYPO3 CMS  TYPO3_7-6
EnvironmentAndFolders.php
Go to the documentation of this file.
1 <?php
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 
25 {
33  public function execute()
34  {
36  $folderStructureFactory = $this->objectManager->get(\TYPO3\CMS\Install\FolderStructure\DefaultFactory::class);
38  $structureFacade = $folderStructureFactory->getStructure();
39  $structureFixMessages = $structureFacade->fix();
41  $statusUtility = $this->objectManager->get(\TYPO3\CMS\Install\Status\StatusUtility::class);
42  $errorsFromStructure = $statusUtility->filterBySeverity($structureFixMessages, 'error');
43 
44  if (@is_dir(PATH_typo3conf)) {
46  $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
47  $configurationManager->createLocalConfigurationFromFactoryConfiguration();
48 
49  // Create a PackageStates.php with all packages activated marked as "part of factory default"
50  if (!file_exists(PATH_typo3conf . 'PackageStates.php')) {
52  $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getEarlyInstance(\TYPO3\CMS\Core\Package\PackageManager::class);
53  $packages = $packageManager->getAvailablePackages();
54  foreach ($packages as $package) {
56  if ($package instanceof \TYPO3\CMS\Core\Package\PackageInterface
57  && $package->isPartOfFactoryDefault()
58  ) {
59  $packageManager->activatePackage($package->getPackageKey());
60  }
61  }
62  $packageManager->forceSortAndSavePackageStates();
63  }
64 
65  // Create enable install tool file after typo3conf & LocalConfiguration were created
67  $installToolService = $this->objectManager->get(\TYPO3\CMS\Install\Service\EnableFileService::class);
68  $installToolService->removeFirstInstallFile();
69  $installToolService->createInstallToolEnableFile();
70  }
71 
72  return $errorsFromStructure;
73  }
74 
80  public function needsExecution()
81  {
82  if (@is_file(PATH_typo3conf . 'LocalConfiguration.php')) {
83  return false;
84  } else {
85  return true;
86  }
87  }
88 
94  protected function executeAction()
95  {
97  $statusCheck = $this->objectManager->get(\TYPO3\CMS\Install\SystemEnvironment\Check::class);
98  $statusObjects = $statusCheck->getStatus();
100  $statusUtility = $this->objectManager->get(\TYPO3\CMS\Install\Status\StatusUtility::class);
101  $environmentStatus = $statusUtility->sortBySeverity($statusObjects);
102  $alerts = $statusUtility->filterBySeverity($statusObjects, 'alert');
103  $this->view->assign('alerts', $alerts);
104  $this->view->assign('environmentStatus', $environmentStatus);
105 
107  $folderStructureFactory = $this->objectManager->get(\TYPO3\CMS\Install\FolderStructure\DefaultFactory::class);
109  $structureFacade = $folderStructureFactory->getStructure();
110  $structureMessages = $structureFacade->getStatus();
112  $structureErrors = $statusUtility->filterBySeverity($structureMessages, 'error');
113  $this->view->assign('structureErrors', $structureErrors);
114 
115  if (!empty($environmentStatus['error']) || !empty($environmentStatus['warning']) || !empty($structureErrors)) {
116  $this->view->assign('errorsOrWarningsFromStatus', true);
117  }
118  $this->assignSteps();
119 
120  return $this->view->render(!empty($alerts));
121  }
122 }