TYPO3 CMS  TYPO3_7-6
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 
61  public function initializeObject()
62  {
64  }
65 
70  {
71  if ($this->environmentService->isEnvironmentInFrontendMode()) {
72  $this->concreteConfigurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager::class);
73  } else {
74  $this->concreteConfigurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager::class);
75  }
76  }
77 
82  public function setContentObject(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject = null)
83  {
84  $this->concreteConfigurationManager->setContentObject($contentObject);
85  }
86 
90  public function getContentObject()
91  {
92  return $this->concreteConfigurationManager->getContentObject();
93  }
94 
102  public function setConfiguration(array $configuration = [])
103  {
104  $this->concreteConfigurationManager->setConfiguration($configuration);
105  }
106 
124  public function getConfiguration($configurationType, $extensionName = null, $pluginName = null)
125  {
126  switch ($configurationType) {
127  case self::CONFIGURATION_TYPE_SETTINGS:
128  $configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
129  return $configuration['settings'];
130  case self::CONFIGURATION_TYPE_FRAMEWORK:
131  return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
132  case self::CONFIGURATION_TYPE_FULL_TYPOSCRIPT:
133  return $this->concreteConfigurationManager->getTypoScriptSetup();
134  default:
135  throw new \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879);
136  }
137  }
138 
149  public function isFeatureEnabled($featureName)
150  {
151  $configuration = $this->getConfiguration(self::CONFIGURATION_TYPE_FRAMEWORK);
152  return (bool)(isset($configuration['features'][$featureName]) && $configuration['features'][$featureName]);
153  }
154 }
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)