本文整理汇总了PHP中Zend_Translate_Adapter::setCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate_Adapter::setCache方法的具体用法?PHP Zend_Translate_Adapter::setCache怎么用?PHP Zend_Translate_Adapter::setCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Translate_Adapter
的用法示例。
在下文中一共展示了Zend_Translate_Adapter::setCache方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTranslate
/**
* Retrieve translate object
*
* @throws Zend_Application_Resource_Exception if registry key was used
* already but is no instance of Zend_Translate
* @return Zend_Translate
*/
public function getTranslate()
{
if (null === $this->_translate) {
$this->buildLog();
// retrieve cache if requested
if (isset($this->_options['cacheEnabled']) && $this->_options['cacheEnabled']) {
// check for cachemanager in bootstrap
if (!$this->getBootstrap()->hasPluginResource('cachemanager')) {
throw new Zend_Application_Resource_Exception("You must configure the cachemanager with " . "the key {$this->getCacheKey()}");
}
// bootstrap the cachemanager and retrieve it
/** @var $cacheManager Zend_Cache_Manager */
$cacheManager = $this->getBootstrap()->bootstrap('cachemanager')->getResource('cachemanager');
// check for the given key
if (!$cacheManager->hasCache($this->getCacheKey())) {
throw new Zend_Application_Resource_Exception("You must configure the cachemanager with " . "the key {$this->getCacheKey()}");
}
// set cache for translator
Zend_Translate_Adapter::setCache($cacheManager->getCache($this->getCacheKey()));
}
// fetch translate object into local variable
$this->_translate = parent::getTranslate();
}
return $this->_translate;
}
示例2: tearDown
protected function tearDown()
{
// restore static variables
if (isset($this->cache)) {
Zend_Translate_Adapter::setCache($this->cache);
unset($this->cache);
} else {
Zend_Translate_Adapter::removeCache();
}
// unset the registry
Zend_Registry::_unsetInstance();
}
示例3: setCache
/**
* Sets a cache for all instances of Zend_Translate
*
* @param Zend_Cache_Core $cache Cache to store to
* @return void
*/
public static function setCache(Zend_Cache_Core $cache)
{
Zend_Translate_Adapter::setCache($cache);
}