[TASK] Use fully qualified name resolution in PHP 5.5
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Configuration / ConfigurationManager.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Configuration;
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 /**
17 * A configuration manager following the strategy pattern (GoF315). It hides the concrete
18 * implementation of the configuration manager and provides an unified acccess point.
19 *
20 * Use the shutdown() method to drop the concrete implementation.
21 */
22 class ConfigurationManager implements \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface {
23
24 /**
25 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
26 * @inject
27 */
28 protected $objectManager;
29
30 /**
31 * @var \TYPO3\CMS\Extbase\Configuration\AbstractConfigurationManager
32 */
33 protected $concreteConfigurationManager;
34
35 /**
36 * @var \TYPO3\CMS\Extbase\Service\EnvironmentService
37 * @inject
38 */
39 protected $environmentService;
40
41 /**
42 * Initializes the object
43 *
44 * @return void
45 */
46 public function initializeObject() {
47 $this->initializeConcreteConfigurationManager();
48 }
49
50 /**
51 * @return void
52 */
53 protected function initializeConcreteConfigurationManager() {
54 if ($this->environmentService->isEnvironmentInFrontendMode()) {
55 $this->concreteConfigurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\FrontendConfigurationManager::class);
56 } else {
57 $this->concreteConfigurationManager = $this->objectManager->get(\TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager::class);
58 }
59 }
60
61 /**
62 * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject
63 * @return void
64 */
65 public function setContentObject(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject = NULL) {
66 $this->concreteConfigurationManager->setContentObject($contentObject);
67 }
68
69 /**
70 * @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
71 */
72 public function getContentObject() {
73 return $this->concreteConfigurationManager->getContentObject();
74 }
75
76 /**
77 * Sets the specified raw configuration coming from the outside.
78 * Note that this is a low level method and only makes sense to be used by Extbase internally.
79 *
80 * @param array $configuration The new configuration
81 * @return void
82 */
83 public function setConfiguration(array $configuration = array()) {
84 $this->concreteConfigurationManager->setConfiguration($configuration);
85 }
86
87 /**
88 * Returns the specified configuration.
89 * The actual configuration will be merged from different sources in a defined order.
90 *
91 * You can get the following types of configuration invoking:
92 * CONFIGURATION_TYPE_SETTINGS: Extbase settings
93 * CONFIGURATION_TYPE_FRAMEWORK: the current module/plugin settings
94 * CONFIGURATION_TYPE_FULL_TYPOSCRIPT: a raw TS array
95 *
96 * Note that this is a low level method and only makes sense to be used by Extbase internally.
97 *
98 * @param string $configurationType The kind of configuration to fetch - must be one of the CONFIGURATION_TYPE_* constants
99 * @param string $extensionName if specified, the configuration for the given extension will be returned.
100 * @param string $pluginName if specified, the configuration for the given plugin will be returned.
101 * @throws Exception\InvalidConfigurationTypeException
102 * @return array The configuration
103 */
104 public function getConfiguration($configurationType, $extensionName = NULL, $pluginName = NULL) {
105 switch ($configurationType) {
106 case self::CONFIGURATION_TYPE_SETTINGS:
107 $configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
108 return $configuration['settings'];
109 case self::CONFIGURATION_TYPE_FRAMEWORK:
110 return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName);
111 case self::CONFIGURATION_TYPE_FULL_TYPOSCRIPT:
112 return $this->concreteConfigurationManager->getTypoScriptSetup();
113 default:
114 throw new \TYPO3\CMS\Extbase\Configuration\Exception\InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879);
115 }
116 }
117
118 /**
119 * Returns TRUE if a certain feature, identified by $featureName
120 * should be activated, FALSE for backwards-compatible behavior.
121 *
122 * This is an INTERNAL API used throughout Extbase and Fluid for providing backwards-compatibility.
123 * Do not use it in your custom code!
124 *
125 * @param string $featureName
126 * @return bool
127 */
128 public function isFeatureEnabled($featureName) {
129 $configuration = $this->getConfiguration(self::CONFIGURATION_TYPE_FRAMEWORK);
130 return (bool)(isset($configuration['features'][$featureName]) && $configuration['features'][$featureName]);
131 }
132 }