TYPO3 CMS  TYPO3_7-6
Configuration.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 
18 
23 {
27  protected $featureManager;
28 
32  protected $configurationManager = null;
33 
37  public function injectFeatureManager(\TYPO3\CMS\Install\Configuration\FeatureManager $featureManager)
38  {
39  $this->featureManager = $featureManager;
40  }
41 
45  public function injectConfigurationManager(\TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager)
46  {
47  $this->configurationManager = $configurationManager;
48  }
49 
55  protected function executeAction()
56  {
57  $actionMessages = [];
58  if (isset($this->postValues['set']['activate'])) {
59  $actionMessages[] = $this->activate();
60  $this->activate();
61  }
62  $this->view->assign('actionMessages', $actionMessages);
63 
64  $postValues = is_array($this->postValues['values']) ? $this->postValues['values'] : [];
65  $this->view->assign('features', $this->featureManager->getInitializedFeatures($postValues));
66 
67  return $this->view->render();
68  }
69 
75  protected function activate()
76  {
77  $configurationValues = $this->featureManager->getConfigurationForSelectedFeaturePresets($this->postValues['values']);
78 
79  if (!empty($configurationValues)) {
80  $this->configurationManager->setLocalConfigurationValuesByPathValuePairs($configurationValues);
82  $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\OkStatus::class);
83  $message->setTitle('Configuration written');
84  $messageBody = [];
85  foreach ($configurationValues as $configurationKey => $configurationValue) {
86  $messageBody[] = '\'' . $configurationKey . '\' => \'' . $configurationValue . '\'';
87  }
88  $message->setMessage(implode(LF, $messageBody));
89  } else {
91  $message = $this->objectManager->get(\TYPO3\CMS\Install\Status\InfoStatus::class);
92  $message->setTitle('No configuration change selected');
93  }
94  return $message;
95  }
96 }
injectConfigurationManager(\TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager)
injectFeatureManager(\TYPO3\CMS\Install\Configuration\FeatureManager $featureManager)