‪TYPO3CMS  10.4
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 
24 
33 {
37  protected ‪$objectManager;
38 
43 
47  protected ‪$environmentService;
48 
53  public function ‪__construct(
56  ) {
57  $this->objectManager = ‪$objectManager;
58  $this->environmentService = ‪$environmentService;
59 
61  }
62 
63  protected function ‪initializeConcreteConfigurationManager(): void
64  {
65  if ($this->environmentService->isEnvironmentInFrontendMode()) {
66  $this->concreteConfigurationManager = $this->objectManager->get(FrontendConfigurationManager::class);
67  } else {
68  $this->concreteConfigurationManager = $this->objectManager->get(BackendConfigurationManager::class);
69  }
70  }
71 
75  public function ‪setContentObject(ContentObjectRenderer $contentObject): void
76  {
77  $this->concreteConfigurationManager->setContentObject($contentObject);
78  }
79 
83  public function ‪getContentObject(): ?ContentObjectRenderer
84  {
85  return $this->concreteConfigurationManager->getContentObject();
86  }
87 
94  public function ‪setConfiguration(array $configuration = []): void
95  {
96  $this->concreteConfigurationManager->setConfiguration($configuration);
97  }
98 
116  public function ‪getConfiguration(string $configurationType, string $extensionName = null, string $pluginName = null): array
117  {
118  switch ($configurationType) {
120  $configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
121  return $configuration['settings'] ?? [];
123  return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
125  return $this->concreteConfigurationManager->getTypoScriptSetup();
126  default:
127  throw new InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879);
128  }
129  }
130 
141  public function ‪isFeatureEnabled(string $featureName): bool
142  {
143  $configuration = $this->‪getConfiguration(self::CONFIGURATION_TYPE_FRAMEWORK);
144  return (bool)(isset($configuration['features'][$featureName]) && $configuration['features'][$featureName]);
145  }
146 }
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\$concreteConfigurationManager
‪TYPO3 CMS Extbase Configuration AbstractConfigurationManager $concreteConfigurationManager
Definition: ConfigurationManager.php:40
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\isFeatureEnabled
‪bool isFeatureEnabled(string $featureName)
Definition: ConfigurationManager.php:138
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\getContentObject
‪TYPO3 CMS Frontend ContentObject ContentObjectRenderer null getContentObject()
Definition: ConfigurationManager.php:80
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\getConfiguration
‪array getConfiguration(string $configurationType, string $extensionName=null, string $pluginName=null)
Definition: ConfigurationManager.php:113
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Extbase\Object\ObjectManagerInterface
Definition: ObjectManagerInterface.php:26
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\$environmentService
‪TYPO3 CMS Extbase Service EnvironmentService $environmentService
Definition: ConfigurationManager.php:44
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FRAMEWORK
‪const CONFIGURATION_TYPE_FRAMEWORK
Definition: ConfigurationManagerInterface.php:29
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer\getContentObject
‪AbstractContentObject null getContentObject($name)
Definition: ContentObjectRenderer.php:754
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager
Definition: ConfigurationManager.php:33
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\initializeConcreteConfigurationManager
‪initializeConcreteConfigurationManager()
Definition: ConfigurationManager.php:60
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\setConfiguration
‪setConfiguration(array $configuration=[])
Definition: ConfigurationManager.php:91
‪TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException
Definition: InvalidConfigurationTypeException.php:26
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_FULL_TYPOSCRIPT
‪const CONFIGURATION_TYPE_FULL_TYPOSCRIPT
Definition: ConfigurationManagerInterface.php:31
‪TYPO3\CMS\Extbase\Service\EnvironmentService
Definition: EnvironmentService.php:27
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface\CONFIGURATION_TYPE_SETTINGS
‪const CONFIGURATION_TYPE_SETTINGS
Definition: ConfigurationManagerInterface.php:30
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\$objectManager
‪TYPO3 CMS Extbase Object ObjectManagerInterface $objectManager
Definition: ConfigurationManager.php:36
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\setContentObject
‪setContentObject(ContentObjectRenderer $contentObject)
Definition: ConfigurationManager.php:72
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager\__construct
‪__construct(ObjectManagerInterface $objectManager, EnvironmentService $environmentService)
Definition: ConfigurationManager.php:50
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:97
‪TYPO3\CMS\Extbase\Configuration
Definition: AbstractConfigurationManager.php:18