本文整理汇总了PHP中Zend_Locale::setCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::setCache方法的具体用法?PHP Zend_Locale::setCache怎么用?PHP Zend_Locale::setCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Locale
的用法示例。
在下文中一共展示了Zend_Locale::setCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
if (null === $this->_cache) {
$options = $this->getOptions();
if (!isset($options[0]) && $options) {
if (!isset($options['frontend']['adapter'])) {
$options['frontend']['adapter'] = 'Core';
}
if (!isset($options['backend']['adapter'])) {
$options['backend']['adapter'] = 'Memcached';
}
if (!isset($options['frontend']['params'])) {
$options['frontend']['params'] = array();
}
if (!isset($options['backend']['params'])) {
$options['backend']['params'] = array();
}
$this->_cache = Zend_Cache::factory($options['frontend']['adapter'], $options['backend']['adapter'], $options['frontend']['params'], $options['backend']['params']);
if (isset($options['metadata']) && true === (bool) $options['metadata']) {
Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
}
if (isset($options['translate']) && true === (bool) $options['translate']) {
Zend_Translate::setCache($this->_cache);
}
if (isset($options['locale']) && true === (bool) $options['locale']) {
Zend_Locale::setCache($this->_cache);
}
} else {
$this->_cache = false;
}
$key = isset($options['registry']) && !is_numeric($options['registry']) ? $options['registry'] : self::DEFAULT_REGISTRY_KEY;
Zend_Registry::set($key, $this->_cache);
}
return $this->_cache;
}
示例2: __invoke
/**
* @param \HumusMvc\MvcEvent $e
* @return void
*/
public function __invoke(MvcEvent $e)
{
$serviceManager = $e->getApplication()->getServiceManager();
$config = $serviceManager->get('Config');
if (!isset($config['locale'])) {
// no locale config found, return
return;
}
// set cache in locale to speed up application
if ($serviceManager->has('CacheManager')) {
$cacheManager = $serviceManager->get('CacheManager');
Locale::setCache($cacheManager->getCache('default'));
}
$options = $config['locale'];
if (!isset($options['default'])) {
$locale = new Locale();
} elseif (!isset($options['force']) || (bool) $options['force'] == false) {
// Don't force any locale, just go for auto detection
Locale::setDefault($options['default']);
$locale = new Locale();
} else {
$locale = new Locale($options['default']);
}
$key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
Registry::set($key, $locale);
}
示例3: setUp
public function setUp()
{
require_once 'Zend/Cache.php';
$cache = Zend_Cache::factory('Core', 'File',
array('lifetime' => 120, 'automatic_serialization' => true),
array('cache_dir' => dirname(__FILE__) . '/_files/'));
Zend_Locale::setCache($cache);
}
示例4: _initCache
protected function _initCache()
{
$aFrontendConf = array('lifetime' => 345600, 'automatic_seralization' => true);
$aBackendConf = array('cache_dir' => APPLICATION_PATH . '/../tmp/');
$oCache = Zend_Cache::factory('Core', 'File', $aFrontendConf, $aBackendConf);
$oCache->setOption('automatic_serialization', true);
Zend_Locale::setCache($oCache);
}
示例5: _initCache
protected function _initCache()
{
$frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => APPLICATION_PATH . '/tmp/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Registry::set('cache', $cache);
// DON'T KNOW WHY: zend locale is having trouble finding it's default cache directory
// so using our zite cache as a quick fix
Zend_Locale::setCache($cache);
return $cache;
}
示例6: _initCache
public function _initCache()
{
mb_internal_encoding("UTF-8");
$frontend = array('lifetime' => 7200, 'automatic_serialization' => true);
$cachedir = realpath(APPLICATION_PATH . '/data/cache');
$backend = array('cache_dir' => $cachedir);
$cache = Zend_Cache::factory('Core', 'File', $frontend, $backend);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
Zend_Registry::set('cache', $cache);
// Cache dos Objetos Date. Utilize sempre. A não utilizaçao causa erros no zend cache.
Zend_Locale::setCache($cache);
}
示例7: _initZendCache
/**
* Setup zend cache directory.
*
* @return void
*/
protected function _initZendCache()
{
$this->bootstrap('Configuration');
$config = $this->getResource('Configuration');
$frontendOptions = array('lifetime' => 600, 'automatic_serialization' => true);
$backendOptions = array('cache_dir' => $config->workspacePath . '/cache/');
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Translate::setCache($cache);
Zend_Locale::setCache($cache);
Zend_Locale_Data::setCache($cache);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
return $cache;
}
示例8: _initCache
/**
* Set caching
*
* @return void
*/
public function _initCache()
{
if (!Zend_Registry::isRegistered('cachemanager')) {
return false;
}
$cache = HCMS_Cache::getInstance()->getCoreCache();
//set cache for table metadata
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
//set cache for locale
Zend_Locale::setCache($cache);
//set cache for translate
Zend_Translate::setCache($cache);
//plugin loader cache
$classFileIncCache = APPLICATION_PATH . '/../cache/file/pluginLoaderCache.php';
if (file_exists($classFileIncCache)) {
include_once $classFileIncCache;
}
Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
}
示例9: _setCache
/**
* Sets the locale cache
*
* @return void
*/
protected function _setCache()
{
$options = $this->getOptions();
// Disable cache? If not defined, cache will be active
if (isset($options['cache']['active']) && !$options['cache']['active']) {
// Zend by default creates a cache for Zend_Locale, due to performance
// considerations. Manually disable cache to override that behaviour.
Zend_Locale::disableCache(true);
return;
}
// Get the cache using the config settings as input
$this->_bootstrap->bootstrap('CacheManager');
$manager = $this->_bootstrap->getResource('CacheManager');
$cache = $manager->getCache('locale');
// Write caching errors to log file (if activated in the config)
$this->_bootstrap->bootstrap('Log');
$logger = $this->_bootstrap->getResource('Log');
$cache->setOption('logger', $logger);
Zend_Locale::setCache($cache);
}
示例10: __construct
/**
* Constructor
*
* Initialize application. Potentially initializes include_paths, PHP
* settings, and bootstrap class.
*
* It also loads the default config file for the HausDesign CMS.
*
* @param string $environment
* @param string|array|Zend_Config $options String path to configuration file, or array/Zend_Config
* of configuration options
* @throws Zend_Application_Exception When invalid options are provided
* @throws HausDesign_Application_Exception When invalid general options are provided
* @return void
*/
public function __construct($environment, $options = null)
{
parent::__construct($environment, $options);
$this->_parseUrl();
define('CUR_APPLICATION_PATH', realpath(APPLICATION_PATH . '' . DIRECTORY_SEPARATOR . '' . $this->_application . '' . DIRECTORY_SEPARATOR));
// Get the application specific file
// Normally located at /application/*application name*/configs/application.ini
$applicationOptions = array();
$applicationConfigFile = CUR_APPLICATION_PATH . '' . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR . 'application.ini';
if (file_exists($applicationConfigFile)) {
$applicationOptions = $this->_loadConfig($applicationConfigFile);
}
// Merge the options and force them into Zend_Application
$this->setOptions($this->mergeOptions($this->getOptions(), $applicationOptions));
// Add the options to the Zend Registry
Zend_Registry::set('config', $this->getOptions());
// FIX FOR IIS CACHE FOLDER START
$config = new Zend_Config_Ini($applicationConfigFile, $environment);
$cache = Zend_Cache::factory('Core', 'File', $config->resources->cachemanager->administrator->frontend->options->toArray(), $config->resources->cachemanager->administrator->backend->options->toArray());
Zend_Locale::setCache($cache);
}
示例11: _initTranslationService
/**
* Init translation services and locale.
*
* @return void
*/
protected function _initTranslationService()
{
// Build the path for the languages folder in the current module
$languagesPath = APPLICATION_PATH . '/languages';
// Setup a cache
$frontendOptions = array();
$backendOptions = array();
$frontendOptions['automatic_serialization'] = true;
$frontendOptions['lifetime'] = '604800';
$frontendOptions['write_control'] = false;
$frontendOptions['master_files'] = array($languagesPath . '/en/messages.mo');
$backendOptions['cache_dir'] = APPLICATION_PATH . '/../zendCache';
$backendOptions['hashed_directory_level'] = 1;
$cache = Zend_Cache::factory('File', 'File', $frontendOptions, $backendOptions);
Zend_Translate::setCache($cache);
Zend_Locale::setCache($cache);
// Register the locale for system-wide use
Zend_Registry::set('Zend_Locale', new Zend_Locale('en'));
// Create a translator
$translator = new Zend_Translate(array('adapter' => 'gettext', 'content' => $languagesPath . '/en/messages.mo', 'locale' => 'en'));
// Register the translator for system-wide use
Zend_Registry::set('Zend_Translate', $translator);
}
示例12: init
public function init()
{
parent::init();
$this->_acl = Application_Model_Acl::getInstance();
$isCron = 0 === strpos($_SERVER['REQUEST_URI'], '/cron');
if (!$isCron) {
$this->_session = Application_Service_Session::getInstance();
}
if ('index' === $this->getParam('controller') && 'unsupported' === $this->getParam('action')) {
// $this->redirect('index/unsupported');
}
$this->_mail = new Application_Service_Mail();
$this->_userRepo = Application_Model_UserRepository::getInstance();
$frontendOptions = ['lifetime' => 60, 'automatic_serialization' => true];
$backendOptions = ['cache_dir' => substr(APPLICATION_PATH, 0, strrpos(APPLICATION_PATH, '/')) . '/data/cache/'];
$cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
Zend_Registry::set('Zend_Locale', new Zend_Locale('de'));
Zend_Locale::setCache($cache);
if (!$isCron && $this->isLoggedin()) {
if (is_null($this->_session->getColor())) {
$this->_session->setColor(Application_Model_UserSettingRepository::getInstance()->getSetting()->getColor());
}
if (is_null($this->_session->getMenuStatic())) {
$this->_session->setMenuStatic(Application_Model_UserSettingRepository::getInstance()->getSetting()->getMenuStatic());
}
if (is_null($this->_session->getLanguage())) {
$this->_session->setLanguage(Application_Model_UserSettingRepository::getInstance()->getSetting()->getLanguage());
}
}
$this->_translate = Application_Service_Language::getInstance();
Zend_Registry::set('Zend_Translate', $this->_translate);
$this->view->translate = $this->_translate;
if (!$isCron) {
$this->view->staticMenu = intval($this->_session->getMenuStatic());
$this->view->color = $this->_session->getColor();
}
}
示例13: _initCache
protected function _initCache()
{
$cache_dir = Core_Model_Directory::getCacheDirectory(true);
if (is_writable($cache_dir)) {
$frontendConf = array('lifetime' => 345600, 'automatic_seralization' => true);
$backendConf = array('cache_dir' => $cache_dir);
$cache = Zend_Cache::factory('Core', 'File', $frontendConf, $backendConf);
$cache->setOption('automatic_serialization', true);
Zend_Locale::setCache($cache);
Zend_Registry::set('cache', $cache);
}
}
示例14: _initCache
/**
* Initializes a cache adapter in the following order of precedence:
* 1) application/config/config.ini section if available:
* Example: cache.backend.* (see config for details)
* 2) W3 Super Cache Memcache connection
* 3) APC (if installed)
* 4) SQLite (if installed) in cache/cache.sqlite.db
* 5) File based, in cache/cache.obj
*
* It is recommended to configure your caching connection in the config
* file.
*
* @return Zend
*/
protected function _initCache()
{
$config = $this->bootstrap('config')
->getResource('config');
if (isset($config->cache->backend->memcached)) {
$adapterName = 'Libmemcached';
$options = $config->cache->backend->memcached->toArray();
} elseif (isset($config->cache->backend->memcache)) {
$adapterName = 'Memcached';
$options = $config->cache->backend->memcache->toArray();
} elseif (isset($config->cache->backend->apc)) {
$adapterName = 'Apc';
$options = $config->cache->backend->apc->toArray();
} elseif (isset($config->cache->backend->xcache)) {
$adapterName = 'Xcache';
$options = $config->cache->backend->xcache->toArray();
} elseif (isset($config->cache->backend->sqlite)) {
$adapterName = 'Sqlite';
$options = $config->cache->backend->sqlite->toArray();
} elseif (isset($config->cache->backend->file)) {
$adapterName = 'File';
$options = $config->cache->backend->file->toArray();
} else {
// Auto-detect best available option
if (extension_loaded('apc')) {
$adapterName = 'Apc';
$options = array();
} elseif (extension_loaded('sqlite')) {
$adapterName = 'Sqlite';
$options = array(
'cache_db_complete_path' => PROJECT_BASE_PATH . '/cache/cache.sqlite.db'
);
} else {
$adapterName = 'File';
$options = array(
'cache_dir' => PROJECT_BASE_PATH . '/cache',
'file_locking' => true
);
}
}
if (isset($config->cache->frontend)) {
$frontendOptions = $config->cache->frontend->toArray();
} else {
$frontendOptions = array(
'lifetime' => 3600,
'logging' => false,
'automatic_serialization' => true
);
}
$cache = Zend_Cache::factory('Core', $adapterName, $frontendOptions, $options);
Zend_Registry::set('cache', $cache);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
Zend_Date::setOptions(array('cache' => $cache));
Zend_Locale::setCache($cache);
return $cache;
}
示例15: _initLocale
protected function _initLocale()
{
$config = Application_Model_Mappers_ConfigMapper::getInstance()->getConfig();
$name = Zend_Locale::getLocaleToTerritory($config['language']);
if ($name !== null) {
$locale = new Zend_Locale($name);
} else {
$locale = new Zend_Locale();
}
$locale->setCache(Zend_Registry::get('cache'));
Zend_Registry::set('Zend_Locale', $locale);
}