‪TYPO3CMS  9.5
FeatureManager.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 
22 
28 {
32  protected ‪$featureRegistry = [
33  ContextFeature::class,
34  ImageFeature::class,
35  MailFeature::class,
36  PasswordHashingFeature::class,
37  ];
38 
46  public function ‪getInitializedFeatures(array $postValues = [])
47  {
48  $features = [];
49  foreach ($this->featureRegistry as $featureClass) {
51  $featureInstance = GeneralUtility::makeInstance($featureClass);
52  if (!($featureInstance instanceof ‪FeatureInterface)) {
53  throw new ‪Exception(
54  'Feature ' . $featureClass . ' does not implement FeatureInterface',
55  1378644593
56  );
57  }
58  $featureInstance->initializePresets($postValues);
59  $features[] = $featureInstance;
60  }
61  return $features;
62  }
63 
71  public function ‪getConfigurationForSelectedFeaturePresets(array $postValues)
72  {
73  $localConfigurationValuesToSet = [];
74  $features = $this->‪getInitializedFeatures($postValues);
75  foreach ($features as $feature) {
77  $featureName = $feature->getName();
78  $presets = $feature->getPresetsOrderedByPriority();
79  foreach ($presets as $preset) {
81  $presetName = $preset->getName();
82  if (!empty($postValues[$featureName]['enable'])
83  && $postValues[$featureName]['enable'] === $presetName
84  && (!$preset->isActive() || $preset instanceof ‪CustomPresetInterface)
85  ) {
86  $localConfigurationValuesToSet = array_merge(
87  $localConfigurationValuesToSet,
88  $preset->getConfigurationValues()
89  );
90  }
91  }
92  }
93  return $localConfigurationValuesToSet;
94  }
95 
103  {
104  $localConfigurationValuesToSet = [];
105  $features = $this->‪getInitializedFeatures([]);
106  foreach ($features as $feature) {
108  $presets = $feature->getPresetsOrderedByPriority();
109  foreach ($presets as $preset) {
110  // Only choose "normal" presets, no custom presets
111  if ($preset instanceof ‪CustomPresetInterface) {
112  break;
113  }
114 
116  if ($preset->isAvailable()) {
117  $localConfigurationValuesToSet = array_merge(
118  $localConfigurationValuesToSet,
119  $preset->getConfigurationValues()
120  );
121  // Setting for this feature done, go to next feature
122  break;
123  }
124  }
125  }
126  return $localConfigurationValuesToSet;
127  }
128 }
‪TYPO3\CMS\Install\Configuration\FeatureManager\getBestMatchingConfigurationForAllFeatures
‪array getBestMatchingConfigurationForAllFeatures()
Definition: FeatureManager.php:101
‪TYPO3\CMS\Install\Configuration\FeatureInterface
Definition: FeatureInterface.php:21
‪TYPO3\CMS\Install\Configuration\FeatureManager
Definition: FeatureManager.php:28
‪TYPO3\CMS\Install\Configuration\PasswordHashing\PasswordHashingFeature
Definition: PasswordHashingFeature.php:26
‪TYPO3\CMS\Install\Configuration\FeatureManager\$featureRegistry
‪array $featureRegistry
Definition: FeatureManager.php:31
‪TYPO3\CMS\Install\Configuration\Image\ImageFeature
Definition: ImageFeature.php:24
‪TYPO3\CMS\Install\Configuration\Exception
Definition: Exception.php:21
‪TYPO3\CMS\Install\Configuration\CustomPresetInterface
Definition: CustomPresetInterface.php:26
‪TYPO3\CMS\Install\Configuration\FeatureManager\getConfigurationForSelectedFeaturePresets
‪array getConfigurationForSelectedFeaturePresets(array $postValues)
Definition: FeatureManager.php:70
‪TYPO3\CMS\Install\Configuration\Context\ContextFeature
Definition: ContextFeature.php:24
‪TYPO3\CMS\Install\Configuration\FeatureManager\getInitializedFeatures
‪FeatureInterface[] getInitializedFeatures(array $postValues=[])
Definition: FeatureManager.php:45
‪TYPO3\CMS\Install\Configuration\Mail\MailFeature
Definition: MailFeature.php:24
‪TYPO3\CMS\Install\Configuration
Definition: AbstractCustomPreset.php:2
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45