/** * Make sure factory returns core * */ public function testFactoryReturnsCore() { $core = Zym_Cache::factory('Core', 'file', array('caching' => false)); $this->assertEquals('Zend_Cache_Core', get_class($core)); $core = Zym_Cache::factory(); $this->assertEquals('Zend_Cache_Core', get_class($core)); }
/** * Setup * * @return void */ public function setup(Zend_Config $config) { // Setup Cache if ($config->get('cache')) { $cache = Zym_Cache::factory('Core'); Zend_Translate::setCache($cache); } $adapter = $config->get('adapter'); $data = $this->_parseDataPath($config->get('data')); $locale = $config->get('locale'); $options = $this->_parseOptions($config->get('options')->toArray()); $translate = new Zend_Translate($adapter, $data, null, $options); // Weird Zend_Translate issues // We cannot set a locale in the constructor $translate->getAdapter()->setLocale($locale); if ((bool) $config->get('registry')->get('enabled')) { /** * @see Zend_Registry */ require_once 'Zend/Registry.php'; Zend_Registry::set($config->get('registry')->get('key'), $translate); } }
/** * Setup * * @return void */ public function setup(Zend_Config $config) { // Setup Cache if ($config->get('cache')) { $cache = Zym_Cache::factory('Core'); Zend_Translate::setCache($cache); } $adapter = $config->get('adapter'); $data = $this->_parseDataPath($config->get('data')); $options = $this->_parseOptions($config->get('options')->toArray()); if (!($locale = $config->get('locale'))) { if (Zend_Registry::isRegistered('Zend_Locale')) { $locale = Zend_Registry::get('Zend_Locale'); } } $translate = new Zend_Translate($adapter, $data, $locale, $options); if ((bool) $config->get('registry')->get('enabled')) { /** * @see Zend_Registry */ require_once 'Zend/Registry.php'; Zend_Registry::set($config->get('registry')->get('key'), $translate); } }
/** * Set cache * * @param Zend_Config $config */ protected function _setCache(Zend_Config $config) { if (!$config->get('cache')) { return; } /** * @see Zym_Cache */ require_once 'Zym/Cache.php'; $cache = Zym_Cache::factory('Core'); call_user_func(array($this->_class, 'setCache'), $cache); }
/** * Set cache * * @param Zend_Config $config */ protected function _setCache(Zend_Config $config) { if (!$config->get('cache')) { return; } $cache = Zym_Cache::factory('Core'); call_user_func(array($this->_class, 'setCache'), $cache); }
<?php $coreCache = Zym_Cache::factory(); $server = new Zend_XmlRpc_Server(); if (!Zym_XmlRpc_Server_Cache::get('myCacheId', $coreCache, $server)) { require_once 'Some/Service/Class.php'; require_once 'Another/Service/Class.php'; // Attach Some_Service_Class with namespace 'some' $server->setClass('Some_Service_Class', 'some'); // Attach Another_Service_Class with namespace 'another' $server->setClass('Another_Service_Class', 'another'); Zym_XmlRpc_Server_Cache::save('myCacheId', $coreCache, $server); } $response = $server->handle(); echo $response;
/** * Get cache obj * * @return Zend_Cache_Core */ public function getCache() { if ($this->_cache === null) { /** * @see Zym_Cache */ require_once 'Zym/Cache.php'; $cache = Zym_Cache::factory('Core'); $this->setCache($cache); } return $this->_cache; }
<?php // Create a Zend_Cache_Core_Function cache object $cache = Zym_Cache::factory('Function'); // Create a Zend_Cache_Core cache object // Specifying 'Core' is optional since its // the default param $cache = Zym_Cache::factory(); // Create a custom core object with custom // backend // In this instance, any keys here override the default // config settings applied via Zym_Cache::setConfig(); $fOptions = array('cache_id_prefix' => 'bar_'); $bOptions = array('cache_dir' => '../cache'); $cache = Zym_Cache::factory('Core', 'File', $fOptions, $bOptions);