‪TYPO3CMS  11.5
ConfigurationManager.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
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 
19 
20 use Psr\Container\ContainerInterface;
21 use Psr\Http\Message\ServerRequestInterface;
24 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
25 
33 {
34  private ContainerInterface ‪$container;
35 
40 
41  public function ‪__construct(ContainerInterface ‪$container)
42  {
43  $this->container = ‪$container;
45  }
46 
47  protected function ‪initializeConcreteConfigurationManager(): void
48  {
49  if ((‪$GLOBALS['TYPO3_REQUEST'] ?? null) instanceof ServerRequestInterface
50  && ‪ApplicationType::fromRequest(‪$GLOBALS['TYPO3_REQUEST'])->isFrontend()
51  ) {
52  $this->concreteConfigurationManager = $this->container->get(FrontendConfigurationManager::class);
53  } else {
54  $this->concreteConfigurationManager = $this->container->get(BackendConfigurationManager::class);
55  }
56  }
57 
61  public function ‪setContentObject(ContentObjectRenderer $contentObject): void
62  {
63  $this->concreteConfigurationManager->setContentObject($contentObject);
64  }
65 
69  public function ‪getContentObject(): ?ContentObjectRenderer
70  {
71  return $this->concreteConfigurationManager->getContentObject();
72  }
73 
80  public function ‪setConfiguration(array $configuration = []): void
81  {
82  $this->concreteConfigurationManager->setConfiguration($configuration);
83  }
84 
102  public function ‪getConfiguration(string $configurationType, ?string $extensionName = null, ?string $pluginName = null): array
103  {
104  switch ($configurationType) {
106  $configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
107  return $configuration['settings'] ?? [];
109  return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
111  return $this->concreteConfigurationManager->getTypoScriptSetup();
112  default:
113  throw new InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879);
114  }
115  }
116 
127  public function ‪isFeatureEnabled(string $featureName): bool
128  {
129  $configuration = $this->‪getConfiguration(self::CONFIGURATION_TYPE_FRAMEWORK);
130  return (bool)(isset($configuration['features'][$featureName]) && $configuration['features'][$featureName]);
131  }
132 }
‪TYPO3\CMS\Core\Http\ApplicationType\fromRequest
‪static static fromRequest(ServerRequestInterface $request)
Definition: ApplicationType.php:62
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\isFeatureEnabled
‪bool isFeatureEnabled(string $featureName)
Definition: ConfigurationManager.php:126
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\getContentObject
‪TYPO3 CMS Frontend ContentObject ContentObjectRenderer null getContentObject()
Definition: ConfigurationManager.php:68
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager
Definition: AbstractConfigurationManager.php:34
‪TYPO3\CMS\Core\Http\ApplicationType
Definition: ApplicationType.php:52
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK
‪const CONFIGURATION_TYPE_FRAMEWORK
Definition: ConfigurationManagerInterface.php:29
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager
Definition: ConfigurationManager.php:33
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\initializeConcreteConfigurationManager
‪initializeConcreteConfigurationManager()
Definition: ConfigurationManager.php:46
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\setConfiguration
‪setConfiguration(array $configuration=[])
Definition: ConfigurationManager.php:79
‪TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException
Definition: InvalidConfigurationTypeException.php:25
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FULL_TYPOSCRIPT
‪const CONFIGURATION_TYPE_FULL_TYPOSCRIPT
Definition: ConfigurationManagerInterface.php:31
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_SETTINGS
‪const CONFIGURATION_TYPE_SETTINGS
Definition: ConfigurationManagerInterface.php:30
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\__construct
‪__construct(ContainerInterface $container)
Definition: ConfigurationManager.php:40
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\$concreteConfigurationManager
‪AbstractConfigurationManager $concreteConfigurationManager
Definition: ConfigurationManager.php:38
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\$container
‪ContainerInterface $container
Definition: ConfigurationManager.php:34
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\setContentObject
‪setContentObject(ContentObjectRenderer $contentObject)
Definition: ConfigurationManager.php:60
‪TYPO3\CMS\Extbase\Configuration
Definition: AbstractConfigurationManager.php:18
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\getConfiguration
‪array getConfiguration(string $configurationType, ?string $extensionName=null, ?string $pluginName=null)
Definition: ConfigurationManager.php:101