[!!!][TASK] Remove $response preparation in route dispatching
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / Configuration / Features.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Core\Configuration;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 /**
19 * A lightweight API class to check if a feature is enabled.
20 *
21 * Features are simple options (true/false), and are stored in the
22 * global configuration array $TYPO3_CONF_VARS[SYS][features].
23 *
24 * For disabling or enabling a feature the "ConfigurationManager"
25 * should be used.
26 *
27 * -- Naming --
28 *
29 * Feature names should NEVER named "enable" or having a negation, or containing versions or years
30 * "enableFeatureXyz"
31 * "disableOverlays"
32 * "schedulerRevamped"
33 * "useDoctrineQueries"
34 * "disablePreparedStatements"
35 * "disableHooksInFE"
36 *
37 * Proper namings for features
38 * "ExtendedRichtextFormat"
39 * "NativeYamlParser"
40 * "InlinePageTranslations"
41 * "TypoScriptParserIncludesAsXml"
42 * "NativeDoctrineQueries"
43 *
44 * Ideally, these feature switches are added via the Install Tool or via FactoryConfiguration
45 * and can be used for Extensions as well.
46 *
47 * --- Usage ---
48 *
49 * if (GeneralUtility::makeInstance(Features::class)->isFeatureEnabled('InlineSvg')) {
50 * ... do stuff here ...
51 * }
52 */
53 class Features
54 {
55 /**
56 * A list of features that are always activated (mainly happens if a previous feature switch is now always
57 * "turned on" to enforce a behaviour, but still valid for extension authors to ensure the feature switch
58 * returns "enabled" for future versions.
59 *
60 * Usually, this list is kept for 1-2 major versions.
61 *
62 * @var array
63 */
64 protected $alwaysActiveFeatures = [
65 // Enabled in v10.0 at any time, feature switch will be completely ignored in TYPO3 v11.
66 'simplifiedControllerActionDispatching',
67 ];
68
69 /**
70 * Checks if a feature is active
71 *
72 * @param string $featureName the name of the feature
73 * @return bool
74 */
75 public function isFeatureEnabled(string $featureName): bool
76 {
77 if (in_array($featureName, $this->alwaysActiveFeatures, true)) {
78 return true;
79 }
80 return isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['features'][$featureName]) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['features'][$featureName] === true;
81 }
82 }