TYPO3 CMS  TYPO3_8-7
ConfigurationManager.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 
24 {
28  protected $objectManager;
29 
34 
39 
43  public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
44  {
45  $this->objectManager = $objectManager;
46  }
47 
51  public function injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
52  {
53  $this->environmentService = $environmentService;
54  }
55 
59  public function initializeObject()
60  {
62  }
63 
67  {
68  if ($this->environmentService->isEnvironmentInFrontendMode()) {
69  $this->concreteConfigurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager::class);
70  } else {
71  $this->concreteConfigurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager::class);
72  }
73  }
74 
78  public function setContentObject(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject = null)
79  {
80  $this->concreteConfigurationManager->setContentObject($contentObject);
81  }
82 
86  public function getContentObject()
87  {
88  return $this->concreteConfigurationManager->getContentObject();
89  }
90 
97  public function setConfiguration(array $configuration = [])
98  {
99  $this->concreteConfigurationManager->setConfiguration($configuration);
100  }
101 
119  public function getConfiguration($configurationType, $extensionName = null, $pluginName = null)
120  {
121  switch ($configurationType) {
122  case self::CONFIGURATION_TYPE_SETTINGS:
123  $configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
124  return $configuration['settings'];
125  case self::CONFIGURATION_TYPE_FRAMEWORK:
126  return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
127  case self::CONFIGURATION_TYPE_FULL_TYPOSCRIPT:
128  return $this->concreteConfigurationManager->getTypoScriptSetup();
129  default:
130  throw new \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879);
131  }
132  }
133 
144  public function isFeatureEnabled($featureName)
145  {
146  $configuration = $this->getConfiguration(self::CONFIGURATION_TYPE_FRAMEWORK);
147  return (bool)(isset($configuration['features'][$featureName]) && $configuration['features'][$featureName]);
148  }
149 }
injectEnvironmentService(\TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService)
setContentObject(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject=null)
injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
getConfiguration($configurationType, $extensionName=null, $pluginName=null)