1da41f0a290dcdb2f083ee282026e4b5e63a3e52
[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 * Checks if a feature is active
57 *
58 * @param string $featureName the name of the feature
59 * @return bool
60 */
61 public function isFeatureEnabled(string $featureName): bool
62 {
63 return isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['features'][$featureName]) && $GLOBALS['TYPO3_CONF_VARS']['SYS']['features'][$featureName] === true;
64 }
65 }