|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2008-2011 Ingo Renner <ingo@typo3.org> 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 /** 00027 * This cache factory takes care of instantiating a cache frontend and injecting 00028 * a certain cache backend. After creation of the new cache, the cache object 00029 * is registered at the cache manager. 00030 * 00031 * This file is a backport from FLOW3 00032 * 00033 * @package TYPO3 00034 * @subpackage t3lib_cache 00035 * @api 00036 * @version $Id: class.t3lib_cache_factory.php 10121 2011-01-18 20:15:30Z ohader $ 00037 */ 00038 class t3lib_cache_Factory implements t3lib_Singleton { 00039 00040 /** 00041 * A reference to the cache manager 00042 * 00043 * @var t3lib_cache_Manager 00044 */ 00045 protected $cacheManager; 00046 00047 /** 00048 * Injects the cache manager. 00049 * 00050 * This is called by the cache manager itself 00051 * 00052 * @param t3lib_cache_Manager $cacheManager The cache manager 00053 * @return void 00054 * @author Robert Lemke <robert@typo3.org> 00055 * @internal 00056 */ 00057 public function setCacheManager(t3lib_cache_Manager $cacheManager) { 00058 $this->cacheManager = $cacheManager; 00059 } 00060 00061 /** 00062 * Factory method which creates the specified cache along with the specified kind of backend. 00063 * After creating the cache, it will be registered at the cache manager. 00064 * 00065 * @param string $cacheIdentifier The name / identifier of the cache to create 00066 * @param string $cacheName Name of the cache frontend 00067 * @param string $backendName Name of the cache backend 00068 * @param array $backendOptions (optional) Array of backend options 00069 * @return t3lib_cache_frontend_Frontend The created cache frontend 00070 * @author Robert Lemke <robert@typo3.org> 00071 */ 00072 public function create($cacheIdentifier, $cacheName, $backendName, array $backendOptions = array()) { 00073 00074 $backendReference = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheBackends'][$backendName]; 00075 00076 if (strpos($backendReference, ':') === FALSE) { 00077 $backendClassReference = $backendReference; 00078 } else { 00079 t3lib_div::deprecationLog("Configuring cacheBackend with filename is deprecated since TYPO3 4.5. Use the autoloader instead."); 00080 // loading the cache backend file and class 00081 list($backendFile, $backendClassReference) = explode( 00082 ':', 00083 $backendReference 00084 ); 00085 00086 $backendRequireFile = t3lib_div::getFileAbsFileName($backendFile); 00087 if ($backendRequireFile) { 00088 t3lib_div::requireOnce($backendRequireFile); 00089 } 00090 } 00091 00092 $backend = t3lib_div::makeInstance($backendClassReference, $backendOptions); 00093 00094 if (!$backend instanceof t3lib_cache_backend_Backend) { 00095 throw new t3lib_cache_exception_InvalidCache( 00096 '"' . $backendName . '" is not a valid cache backend.', 00097 1216304301 00098 ); 00099 } 00100 00101 $cacheReference = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheFrontends'][$cacheName]; 00102 00103 if (strpos($cacheReference, ':') === FALSE) { 00104 $cacheClassReference = $cacheReference; 00105 } else { 00106 t3lib_div::deprecationLog("Configuring cacheFrontends with filename is deprecated since TYPO3 4.5. Use the autoloader instead."); 00107 // loading the cache frontend file and class 00108 list($cacheFile, $cacheClassReference) = explode( 00109 ':', 00110 $cacheReference 00111 ); 00112 00113 $cacheRequireFile = t3lib_div::getFileAbsFileName($cacheFile); 00114 if ($cacheRequireFile) { 00115 t3lib_div::requireOnce($cacheRequireFile); 00116 } 00117 } 00118 $cache = t3lib_div::makeInstance($cacheClassReference, $cacheIdentifier, $backend); 00119 00120 00121 if (!$cache instanceof t3lib_cache_frontend_Frontend) { 00122 throw new t3lib_cache_exception_InvalidCache( 00123 '"' . $cacheName . '" is not a valid cache.', 00124 1216304300 00125 ); 00126 } 00127 00128 $this->cacheManager->registerCache($cache); 00129 00130 return $cache; 00131 } 00132 00133 } 00134 00135 00136 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/cache/class.t3lib_cache_factory.php'])) { 00137 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/cache/class.t3lib_cache_factory.php']); 00138 } 00139 00140 ?>
1.8.0