‪TYPO3CMS  10.4
FeatureManager.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
24 
30 {
34  protected ‪$featureRegistry = [
35  CacheFeature::class,
36  ContextFeature::class,
37  ImageFeature::class,
38  MailFeature::class,
39  PasswordHashingFeature::class,
40  ];
41 
49  public function ‪getInitializedFeatures(array $postValues = [])
50  {
51  $features = [];
52  foreach ($this->featureRegistry as $featureClass) {
54  $featureInstance = GeneralUtility::makeInstance($featureClass);
55  if (!($featureInstance instanceof ‪FeatureInterface)) {
56  throw new ‪Exception(
57  'Feature ' . $featureClass . ' does not implement FeatureInterface',
58  1378644593
59  );
60  }
61  $featureInstance->initializePresets($postValues);
62  $features[] = $featureInstance;
63  }
64  return $features;
65  }
66 
74  public function ‪getConfigurationForSelectedFeaturePresets(array $postValues)
75  {
76  $localConfigurationValuesToSet = [];
77  $features = $this->‪getInitializedFeatures($postValues);
78  foreach ($features as $feature) {
80  $featureName = $feature->getName();
81  $presets = $feature->getPresetsOrderedByPriority();
82  foreach ($presets as $preset) {
84  $presetName = $preset->getName();
85  if (!empty($postValues[$featureName]['enable'])
86  && $postValues[$featureName]['enable'] === $presetName
87  && (!$preset->isActive() || $preset instanceof ‪CustomPresetInterface)
88  ) {
89  $localConfigurationValuesToSet = array_merge(
90  $localConfigurationValuesToSet,
91  $preset->getConfigurationValues()
92  );
93  }
94  }
95  }
96  return $localConfigurationValuesToSet;
97  }
98 
106  {
107  $localConfigurationValuesToSet = [];
108  $features = $this->‪getInitializedFeatures([]);
109  foreach ($features as $feature) {
111  $presets = $feature->getPresetsOrderedByPriority();
112  foreach ($presets as $preset) {
113  // Only choose "normal" presets, no custom presets
114  if ($preset instanceof ‪CustomPresetInterface) {
115  break;
116  }
117 
119  if ($preset->isAvailable()) {
120  $localConfigurationValuesToSet = array_merge(
121  $localConfigurationValuesToSet,
122  $preset->getConfigurationValues()
123  );
124  // Setting for this feature done, go to next feature
125  break;
126  }
127  }
128  }
129  return $localConfigurationValuesToSet;
130  }
131 }
‪TYPO3\CMS\Install\Configuration\FeatureManager\getBestMatchingConfigurationForAllFeatures
‪array getBestMatchingConfigurationForAllFeatures()
Definition: FeatureManager.php:104
‪TYPO3\CMS\Install\Configuration\FeatureInterface
Definition: FeatureInterface.php:22
‪TYPO3\CMS\Install\Configuration\FeatureManager
Definition: FeatureManager.php:30
‪TYPO3\CMS\Install\Configuration\PasswordHashing\PasswordHashingFeature
Definition: PasswordHashingFeature.php:28
‪TYPO3\CMS\Install\Configuration\Cache\CacheFeature
Definition: CacheFeature.php:26
‪TYPO3\CMS\Install\Configuration\FeatureManager\$featureRegistry
‪array $featureRegistry
Definition: FeatureManager.php:33
‪TYPO3\CMS\Install\Configuration\Image\ImageFeature
Definition: ImageFeature.php:26
‪TYPO3\CMS\Install\Configuration\Exception
Definition: Exception.php:22
‪TYPO3\CMS\Install\Configuration\CustomPresetInterface
Definition: CustomPresetInterface.php:27
‪TYPO3\CMS\Install\Configuration\FeatureManager\getConfigurationForSelectedFeaturePresets
‪array getConfigurationForSelectedFeaturePresets(array $postValues)
Definition: FeatureManager.php:73
‪TYPO3\CMS\Install\Configuration\Context\ContextFeature
Definition: ContextFeature.php:26
‪TYPO3\CMS\Install\Configuration\FeatureManager\getInitializedFeatures
‪FeatureInterface[] getInitializedFeatures(array $postValues=[])
Definition: FeatureManager.php:48
‪TYPO3\CMS\Install\Configuration\Mail\MailFeature
Definition: MailFeature.php:26
‪TYPO3\CMS\Install\Configuration
Definition: AbstractCustomPreset.php:16
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46