/** * Returns a cache * * @return tx_rnbase_cache_ICache */ public static function getCache() { \tx_rnbase::load('tx_rnbase_cache_Manager'); return \tx_rnbase_cache_Manager::getCache('mklog'); }
/** * Returns the database instance * @param string $key database identifier defined in localconf.php. Always in lowercase! * @return tx_rnbase_util_db_IDatabase */ public function getDatabase($key = 'typo3') { $key = strtolower($key); tx_rnbase::load('tx_rnbase_cache_Manager'); $cache = tx_rnbase_cache_Manager::getCache('rnbase_databases'); $db = $cache->get('db_' . $key); if (!$db) { if ($key == 'typo3') { $db = tx_rnbase::makeInstance('tx_rnbase_util_db_TYPO3'); } else { $dbCfg = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['rn_base']['db'][$key]; if (!is_array($dbCfg)) { tx_rnbase::load('tx_rnbase_util_db_Exception'); throw new tx_rnbase_util_db_Exception('No config for database ' . $key . ' found!'); } $db = tx_rnbase::makeInstance('tx_rnbase_util_db_MySQL', $dbCfg); } $cache->set($key, $db); } return $db; }
function test_CacheManager() { tx_rnbase::load('tx_rnbase_cache_Manager'); $cache = tx_rnbase_cache_Manager::getCache('__rnbaseMgrCache__'); $this->assertTrue(is_object($cache), 'No Cache instanciated'); }
/** * check the template for includes * * Examples: (the @ seperates the file from the subpart) * <!-- * Subtemplate fuer dam einbinden * ###INCLUDE_TEMPLATE typo3conf/ext/rn_base/res/simplegallery.html@DAM_IMAGES### * und eingebunden * --> * or * <!-- ### INCLUDE_TEMPLATE EXT:rn_base/res/simplegallery.html@DAM_IMAGES ### --> * * @param string $template * @return string */ public static function includeSubTemplates($template) { // nothing to do, if we dont have a template if (empty($template)) { return $template; } $cache = $included = FALSE; tx_rnbase::load('tx_rnbase_util_TYPO3'); if (!tx_rnbase_util_TYPO3::getTSFE()->no_cache) { tx_rnbase::load('tx_rnbase_cache_Manager'); $cache = tx_rnbase_cache_Manager::getCache('rnbase'); $cacheKey = 'includeSubTemplateFor_' . md5($template); $included = $cache->get($cacheKey); } // search and replace the subparts if (empty($included)) { $included = preg_replace_callback('!\\<\\!--[a-zA-Z0-9_ \\s]*###[ ]*INCLUDE_TEMPLATE([^###]*)\\###[a-zA-Z0-9_ \\s]*-->!is', array(self, 'cbIncludeSubTemplates'), $template); // store the template in the cache if ($cache) { $cache->set($cacheKey, $included); } } return $included; }
/** * returns the cache instance * * @return tx_rnbase_cache_ICache */ protected function getCache() { return tx_rnbase_cache_Manager::getCache($this->getCacheName()); }