|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2009 Jochen Rau <jochen.rau@typoplanet.de> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * A configuration manager following the strategy pattern (GoF315). It hides the concrete 00027 * implementation of the configuration manager and provides an unified acccess point. 00028 * 00029 * Use the shutdown() method to drop the concrete implementation. 00030 * 00031 * @package Extbase 00032 * @subpackage Configuration 00033 * @version $ID:$ 00034 */ 00035 class Tx_Extbase_Configuration_ConfigurationManager implements Tx_Extbase_Configuration_ConfigurationManagerInterface { 00036 00037 /** 00038 * @var Tx_Extbase_Object_ObjectManagerInterface 00039 */ 00040 protected $objectManager; 00041 00042 /** 00043 * @var Tx_Extbase_Configuration_AbstractConfigurationManager 00044 **/ 00045 protected $concreteConfigurationManager; 00046 00047 /** 00048 * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager 00049 * @return void 00050 */ 00051 public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) { 00052 $this->objectManager = $objectManager; 00053 $this->initializeConcreteConfigurationManager(); 00054 } 00055 00056 /** 00057 * @return void 00058 */ 00059 protected function initializeConcreteConfigurationManager() { 00060 if (TYPO3_MODE === 'FE') { 00061 $this->concreteConfigurationManager = $this->objectManager->get('Tx_Extbase_Configuration_FrontendConfigurationManager'); 00062 } else { 00063 $this->concreteConfigurationManager = $this->objectManager->get('Tx_Extbase_Configuration_BackendConfigurationManager'); 00064 } 00065 } 00066 00067 /** 00068 * @param tslib_cObj $contentObject 00069 * @return void 00070 */ 00071 public function setContentObject(tslib_cObj $contentObject = NULL) { 00072 $this->concreteConfigurationManager->setContentObject($contentObject); 00073 } 00074 00075 /** 00076 * @return tslib_cObj 00077 */ 00078 public function getContentObject() { 00079 return $this->concreteConfigurationManager->getContentObject(); 00080 } 00081 00082 /** 00083 * Sets the specified raw configuration coming from the outside. 00084 * Note that this is a low level method and only makes sense to be used by Extbase internally. 00085 * 00086 * @param array $configuration The new configuration 00087 * @return void 00088 */ 00089 public function setConfiguration(array $configuration = array()) { 00090 $this->concreteConfigurationManager->setConfiguration($configuration); 00091 } 00092 00093 /** 00094 * Returns the specified configuration. 00095 * The actual configuration will be merged from different sources in a defined order. 00096 * 00097 * Note that this is a low level method and only makes sense to be used by Extbase internally. 00098 * 00099 * @param string $configurationType The kind of configuration to fetch - must be one of the CONFIGURATION_TYPE_* constants 00100 * @param string $extensionName if specified, the configuration for the given extension will be returned. 00101 * @param string $pluginName if specified, the configuration for the given plugin will be returned. 00102 * @return array The configuration 00103 */ 00104 public function getConfiguration($configurationType, $extensionName = NULL, $pluginName = NULL) { 00105 switch ($configurationType) { 00106 case self::CONFIGURATION_TYPE_SETTINGS : 00107 $configuration = $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName); 00108 return $configuration['settings']; 00109 case self::CONFIGURATION_TYPE_FRAMEWORK : 00110 return $this->concreteConfigurationManager->getConfiguration($extensionName, $pluginName); 00111 case self::CONFIGURATION_TYPE_FULL_TYPOSCRIPT : 00112 return $this->concreteConfigurationManager->getTypoScriptSetup(); 00113 default : 00114 throw new Tx_Extbase_Configuration_Exception_InvalidConfigurationTypeException('Invalid configuration type "' . $configurationType . '"', 1206031879); 00115 } 00116 } 00117 00118 } 00119 ?>
1.8.0