setDefaultMetadataCache() public static method

If $defaultMetadataCache is null, then no metadata cache is used by default.
public static setDefaultMetadataCache ( mixed $metadataCache = null ) : void
$metadataCache mixed Either a Cache object, or a string naming a Registry key
return void
示例#1
0
 protected function _initDbCache()
 {
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => APPLICATION_PATH . '/../cache');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
 }
示例#2
0
 public function _initCache()
 {
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => '../cache/');
     $dbCache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($dbCache);
 }
示例#3
0
 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;
 }
 /**
  * initalize caching
  */
 protected function _initCache()
 {
     $config = vkNgine_Config::getSystemConfig();
     $cache = new vkNgine_Cache($config->cache->use, $config->cache->type);
     Zend_Registry::set('cache', $cache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache->getCacheObject());
 }
 /**
  *  Instantiate the application database resource object
  *
  *  @return Zend_Db_Adapter
  *  @link http://framework.zend.com/manual/en/zend.db.html
  */
 protected function _initDb()
 {
     // Only attempt to cache the metadata if we have a cache available
     if (!is_null($this->_cache)) {
         try {
             Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
         } catch (Zend_Db_Table_Exception $e) {
             print $e->getMessage();
         }
     }
     $db = null;
     $dbPluginResource = $this->getPluginResource('db');
     if (!is_null($dbPluginResource)) {
         $db = $dbPluginResource->getDbAdapter();
         // Set the default fetch mode to object throughout the application
         $db->setFetchMode(Zend_Db::FETCH_OBJ);
         // Force the initial connection to handle error relating to caching etc.
         try {
             $db->getConnection();
         } catch (Zend_Db_Adapter_Exception $e) {
             // perhaps a failed login credential, or perhaps the RDBMS is not running
         } catch (Zend_Exception $e) {
             // perhaps factory() failed to load the specified Adapter class
         }
         Zend_Db_Table::setDefaultAdapter($db);
         Zend_Registry::set('db', $db);
     }
     return $db;
 }
示例#6
0
/**
 * Initizlize Zend DB
 */
function init_zend_db()
{
    try {
        include APPPATH . 'config' . DIRECTORY_SEPARATOR . 'database.php';
        $__dbParams = array('host' => $db[$active_group]['hostname'], 'username' => $db[$active_group]['username'], 'password' => $db[$active_group]['password'], 'dbname' => $db[$active_group]['database'], 'persistent' => $db[$active_group]['pconnect']);
        $__db = Zend_Db::factory('PDO_MYSQL', $__dbParams);
        include APPPATH . 'config/cache.php';
        $feEngine = $config['dbschema_frontend_engine'];
        $feOptions = $config['dbschema_frontend'];
        $beEngine = $config['dbschema_backend_engine'];
        $beOptions = $config['dbschema_backend'];
        if (isset($beOptions['cache_dir']) && !file_exists($beOptions['cache_dir'])) {
            mkdir($beOptions['cache_dir']);
            chmod($beOptions['cache_dir'], 0777);
        }
        //      var_dump($beOptions['cache_dir']);
        $cache = Zend_Cache::factory($feEngine, $beEngine, $feOptions, $beOptions);
        Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
        Zend_Db_Table_Abstract::setDefaultAdapter($__db);
        Profiler::start($db[$active_group], $__db);
        $__db->query('SET NAMES ' . $db['default']['char_set']);
        $__db->query('SET SQL_MODE = "NO_UNSIGNED_SUBTRACTION"');
    } catch (Exception $e) {
        header("HTTP/1.1 500 Internal Server Error (DB)");
        echo $e->getMessage();
        exit;
    }
}
示例#7
0
 /**
  * To init the view
  *
  * @return Zend_View $view
  */
 public function init()
 {
     $frontendOptions = array('automatic_serialization' => true, 'lifetime' => 86400);
     $backendOptions = array('cache_dir' => PROJECT_ROOT . '/repository/cache/');
     if ('development' == APPLICATION_ENV) {
         $frontendOptions['caching'] = false;
         //关闭缓存
     } else {
         $classFileIncCache = $backendOptions['cache_dir'] . 'pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
     $this->_cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_cache);
     //缓存Zend_Db_Table元数据
     Zend_Date::setOptions(array('cache' => $this->_cache));
     //缓存Zend_Date
     Zend_Translate::setCache($this->_cache);
     //缓存Zend_Translate
     Zend_Registry::set('cache', $this->_cache);
     // Return it, so that it can be stored by the bootstrap
     return $this->_cache;
 }
示例#8
0
 public function _initView()
 {
     $this->bootstrap('layout');
     $layout = $this->getResource('layout');
     $v = $layout->getView();
     $v->addHelperPath(APPLICATION_PATH . "/../library/Core/View/Helper", "Core_View_Helper");
     $config = Zend_Registry::get('config');
     $version = self::getVersion();
     $cache = $this->getPluginResource('cachemanager')->getCacheManager()->getCache('default');
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Zend_Registry::set('Cache', $cache);
     $this->getResourceLoader()->addResourceType('entity', 'entitys/', 'Entity');
     defined('STATIC_URL') || define('STATIC_URL', $config['app']['staticUrl']);
     defined('DINAMIC_URL') || define('DINAMIC_URL', $config['app']['dinamicUrl']);
     defined('IMG_URL') || define('IMG_URL', $config['app']['imgUrl']);
     defined('SITE_URL') || define('SITE_URL', $config['app']['siteUrl']);
     defined('SITE_TEMP') || define('SITE_TEMP', $config['app']['elementTemp']);
     defined('SITE_VERSION') || define('SITE_VERSION', $version);
     defined('STATIC_ADMIN_IMG') || define('STATIC_ADMIN_IMG', $config['app']['imgAdmin']);
     defined('ROOT_IMG_DINAMIC') || define('ROOT_IMG_DINAMIC', $config['app']['rootImgDinamic']);
     $doctypeHelper = new Zend_View_Helper_Doctype();
     $doctypeHelper->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT);
     $v->headTitle($config['resources']['view']['title'])->setSeparator(' | ');
     $v->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
     $v->headMeta()->appendName("author", "multibox S.A.C");
     $v->headMeta()->setName("language", "es");
     $v->headMeta()->appendName("description", "portal de contenido de tonos y de musica entel");
     $v->headMeta()->appendName("keywords", "tono,musica,dedicatorias,musica top,realtones,fulltracks, entel, operadora,entretenimiento");
     if (APPLICATION_ENV != 'LOCAL') {
         $this->frontController->throwExceptions(false);
     }
 }
示例#9
0
 /**
  * 
  */
 protected function _initCacheDir()
 {
     $frontendOptions = array('lifetime' => 86400, 'automatic_serialization' => true, 'automatic_cleaning_factor' => 1);
     $backendOptions = array('cache_dir' => APPLICATION_PATH . '/cache');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Zend_Date::setOptions(array('cache' => $cache));
 }
示例#10
0
 /**
  * Set up the caches. Currently, just the db meta cache.
  *
  * @return void
  */
 protected function _initCache()
 {
     // Db metadata cache
     $frontendOptions = array('automatic_serialization' => true);
     $backendOptions = array('cache_dir' => DATA_PATH . 'cache' . DS . 'dbMeta');
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
 }
示例#11
0
 /**
  * @param string $backend
  * @param array  $frontendOptions
  * @param array  $backendOptions
  * @return Zend_Cache_Core
  */
 public function factory($backend, $frontendOptions = [], $backendOptions = [])
 {
     $backend = $this->createBackend($backend, $backendOptions);
     $cacheCore = $this->createCacheCore($frontendOptions);
     $cacheCore->setBackend($backend);
     \Zend_Locale_Data::setCache($cacheCore);
     \Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheCore);
     return $cacheCore;
 }
示例#12
0
 protected function _initCache()
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/' . SITE_NAME . '.ini');
     $cacheFrontendOptions = $config->cache->cache->frontend->toArray();
     $cacheBackendOptions = $config->cache->cache->backend->toArray();
     $cache = Zend_Cache::factory('Core', 'File', $cacheFrontendOptions, $cacheBackendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Zend_Registry::set('cache', $cache);
 }
 public function _initCache()
 {
     $frontendOptions = array('lifetime' => 3600 * 24 * 60, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => '../cache/');
     // получение объекта Zend_Cache_Core
     $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     //cache database table schemata metadata for faster SQL queries
     Zend_Registry::set('cache', $cache);
 }
示例#14
0
 /**
  * Démarrage du gestionnaire de caches, on récupère chaque configuration.
  * Par défaut on met en cache les métadata de la bdd
  *
  * @return void.
  */
 protected function _initCache()
 {
     if ((bool) APP_CACHE) {
         // Récupération des ressources du gestionnaire du cache
         $this->bootstrap('cachemanager');
         // Activation du cache du Zend_Translate
         Zend_Translate::setCache($this->getResource('cachemanager')->getCache('translate'));
         // Activation du cache de la base de données
         Zend_Db_Table_Abstract::setDefaultMetadataCache($this->getResource('cachemanager')->getCache('default'));
     }
 }
示例#15
0
 /**
  * Set default adapter and cache for Zend_Db_Table classes
  *
  * @param Zend_Controller_Request_Abstract $request
  */
 public function routeStartup($request = null)
 {
     Zend_Db_Table_Abstract::setDefaultAdapter(Zoo::getService('db')->getDb());
     $frontendOptions = new Zend_Config(array('lifetime' => 86400));
     try {
         $metacache = Zoo::getService('cache')->getCache('metadata', 'Core', $frontendOptions);
         Zend_Db_Table_Abstract::setDefaultMetadataCache($metacache);
     } catch (Zoo_Exception_Service $e) {
         // No cache service available
     }
 }
示例#16
0
 protected function _initDb()
 {
     try {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->getPluginResource('db')->getDbAdapter());
         Zend_Db_Table_Abstract::setDefaultMetadataCache($this->_getCache('core'));
         Centurion_Db_Table_Abstract::setDefaultBackendOptions(Centurion_Config_Manager::get('resources.cachemanager.class.backend.options'));
         Centurion_Db_Table_Abstract::setDefaultFrontendOptions(Centurion_Config_Manager::get('resources.cachemanager.class.frontend.options'));
     } catch (Exception $e) {
         exit($e->getMessage());
     }
 }
示例#17
0
文件: init.php 项目: hukumonline/idh
 function init()
 {
     define('KUTU_ROOT_DIR', dirname(__FILE__));
     error_reporting(E_ALL | E_STRICT);
     date_default_timezone_set('Asia/Jakarta');
     set_include_path('.' . PATH_SEPARATOR . KUTU_ROOT_DIR . '/library' . PATH_SEPARATOR . get_include_path());
     require_once 'Zend/Loader/Autoloader.php';
     $loader = Zend_Loader_Autoloader::getInstance();
     $loader->setFallbackAutoloader(true);
     $loader->suppressNotFoundWarnings(false);
     //		include "Zend/Loader.php";
     //		Zend_Loader::registerAutoload();
     require_once KUTU_ROOT_DIR . '/library/phpgacl/gacl.class.php';
     require_once KUTU_ROOT_DIR . '/library/phpgacl/gacl_api.class.php';
     require_once KUTU_ROOT_DIR . '/js/jcart/jcart.php';
     $config = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/application.ini', 'general');
     $registry = Zend_Registry::getInstance();
     $registry->set('config', $config);
     $registry->set('files', $_FILES);
     //$db = Zend_Db::factory($config->db->adapter, $config->db->config->toArray());
     //Zend_Db_Table_Abstract::setDefaultAdapter($db);
     $databases = new Zend_Config_Ini(KUTU_ROOT_DIR . '/application/configs/application.ini', 'databases');
     $dbAdapters = array();
     foreach ($databases->db as $config_name => $db) {
         $dbAdapters[$config_name] = Zend_Db::factory($db->adapter, $db->config->toArray());
         if ((bool) $db->default) {
             Zend_Db_Table::setDefaultAdapter($dbAdapters[$config_name]);
         }
     }
     Zend_Registry::set('dbAdapters', $dbAdapters);
     $kutuUtil = new Kutu_Core_Util();
     define('KUTU_ROOT_URL', $kutuUtil->getRootUrl(KUTU_ROOT_DIR));
     require_once 'Kutu/Session/Manager.php';
     $kutuSession = new Kutu_Session_Manager();
     $kutuSession->start();
     // set the expiration time for auth session to expire
     $authNamespace = new Zend_Session_Namespace('Zend_Auth');
     $authNamespace->setExpirationSeconds(86400);
     // will expire in one day
     $frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
     $backendOptions = array('cache_dir' => KUTU_ROOT_DIR . '/data/cache');
     $cacheDbTable = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
     // Next, set the cache to be used with all table objects
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheDbTable);
     //		define('IN_PHPBB', true);
     //		define('PBB_ROOT_PATH', "../phpBB3");
     //		global $phpbb_root_path, $phpEx, $user, $db, $config, $cache, $template;
     //		$phpEx = "php";
     //		$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : PBB_ROOT_PATH . '/';
     //		require_once($phpbb_root_path . 'config.' . $phpEx);
     //		include($phpbb_root_path . 'common.' . $phpEx);
     //		$user->session_begin();
     //		$auth->acl($user->data);
 }
示例#18
0
 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);
 }
示例#19
0
 public function init()
 {
     $options = array_change_key_case($this->getOptions(), CASE_LOWER);
     if (isset($options['enable'])) {
         if ($options['enable']) {
             $frontendOptions = array('lifetime' => 7200, 'automatic_serialization' => true);
             $backendOptions = array('cache_dir' => KUTU_ROOT_DIR . '/tmp/cache');
             $cacheDbTable = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
             Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheDbTable);
         }
     }
 }
示例#20
0
文件: Base.php 项目: alexukua/opus4
 /**
  * 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;
 }
示例#21
0
 public function __construct()
 {
     global $application;
     $prefix = $application->getOption('tablePrefix');
     if (!empty($prefix)) {
         $this->_name = $prefix . $this->_name;
     }
     // cache the meta data for tables so it doesn't have to get it ever time a table is instantiated
     if (Zend_Registry::isRegistered('cache')) {
         $cache = Zend_Registry::get('cache');
         Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     }
     parent::__construct();
 }
 /**
  * Initializates the entity manager
  * 
  */
 public function init()
 {
     require APPLICATION_PATH . '/models/StoresTable.php';
     $this->table = new StoresTable();
     // configure caching backend strategy
     $oBackend = new Zend_Cache_Backend_Memcached(array('servers' => array(array('host' => '127.0.0.1', 'port' => '11211')), 'compression' => true));
     // configure caching logger
     $oCacheLog = new Zend_Log();
     $oCacheLog->addWriter(new Zend_Log_Writer_Stream('C:\\memcache.log'));
     // configure caching frontend strategy
     $oFrontend = new Zend_Cache_Core(array('caching' => true, 'cache_id_prefix' => 'myApp', 'logging' => true, 'logger' => $oCacheLog, 'write_control' => true, 'automatic_serialization' => true, 'ignore_user_abort' => true));
     // build a caching object
     $oCache = Zend_Cache::factory($oFrontend, $oBackend);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($oCache);
 }
示例#23
0
 /**
  * Setup our cache
  */
 protected function _initAppCache()
 {
     $this->bootstrap('cachemanager');
     $metaCache = $this->getResource('cachemanager')->getCache('metadata');
     $dateCache = $this->getResource('cachemanager')->getCache('date');
     Zend_Db_Table_Abstract::setDefaultMetadataCache($metaCache);
     Zend_Date::setOptions(array('cache' => $dateCache));
     if ('production' === $this->getEnvironment()) {
         $classFileIncCache = APPLICATION_PATH . '/tmp/pluginLoaderCache.php';
         if (file_exists($classFileIncCache)) {
             include_once $classFileIncCache;
         }
         Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     }
 }
示例#24
0
文件: Bootstrap.php 项目: abdala/la
 public function _initCache()
 {
     $this->bootstrap('cachemanager');
     $options = $this->getOption('resources');
     if (!$options['cachemanager']['default']['active']) {
         return;
     }
     $cache = $this->getPluginResource('cachemanager')->getCacheManager()->getCache('default');
     $classFileIncCache = APPLICATION_PATH . '/../data/cache/pluginLoaderCache.php';
     if (file_exists($classFileIncCache)) {
         include_once $classFileIncCache;
     }
     Zend_Loader_PluginLoader::setIncludeFileCache($classFileIncCache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Zend_Registry::set('cache', $cache);
 }
示例#25
0
文件: Db.php 项目: bersace/strass
 static function setup($dbname = null, $reset = false)
 {
     if ($dbname === null) {
         $dbname = 'private/strass.sqlite';
     }
     if ($reset) {
         @unlink($dbname);
     }
     $db = Zend_Db::factory('Pdo_SQLite', array('dbname' => $dbname));
     $doProfile = strpos(@$_SERVER['QUERY_STRING'], 'PROFILE') !== false || isset($_ENV['STRASS_UNIT_TEST']);
     $db->getProfiler()->setEnabled($doProfile);
     Zend_Db_Table_Abstract::setDefaultAdapter($db);
     Zend_Registry::set('db', $db);
     $cache = Zend_Registry::get('cache');
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Strass_Db_Table_Abstract::$_rowCache = new Strass_Cache();
     return $db;
 }
示例#26
0
 /**
  * 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);
 }
示例#27
0
 /**
  * Sets the table metadata 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']) {
         // Explicitly pass null to deactivate, in case it was enabled before
         Zend_Db_Table_Abstract::setDefaultMetadataCache(null);
         return;
     }
     // Get the cache using the config settings as input
     $this->_bootstrap->bootstrap('CacheManager');
     $manager = $this->_bootstrap->getResource('CacheManager');
     $cache = $manager->getCache('db');
     // 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_Db_Table_Abstract::setDefaultMetadataCache($cache);
 }
示例#28
0
 protected function _initDB()
 {
     //this is the database from the pitFM-Connection!
     // Check that the config contains the correct database array.
     if ($this->getOption('database')) {
         // Instantiate the DB factory
         $database = $this->getOption('database');
         $dbAdapter = Zend_Db::factory($database['adapter'], $database['params']);
         // Set the DB Table default adaptor for auto connection in the models
         Zend_Db_Table::setDefaultAdapter($dbAdapter);
         Zend_Registry::set("dbAdapter", $dbAdapter);
         $dbAdapter->setFetchMode(Zend_Db::FETCH_OBJ);
         //setup metadata-caching
         $frontendOptions = array('automatic_serialization' => true, 'lifetime' => 30);
         $backendOptions = array('cache_dir' => dirname(__FILE__) . '/cache/');
         $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         // Next, set the cache to be used with all table objects
         Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     }
 }
示例#29
0
文件: Common.php 项目: neosin/reactor
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $config = Zend_Registry::get('config');
     //this is the only place where i want to have another cache instance - for zend_db metadata we should use file cache
     Zend_Db_Table_Abstract::setDefaultMetadataCache(Zend_Registry::get('cache_files'));
     $db = Zend_Db::factory($config->setup->database->adapter, $config->setup->database->config->toArray());
     #TODO did they implement that in 1.7 or still we have to wait :/
     switch ($config->setup->database) {
         case 'PDO_PGSQL':
             $db->query("SET NAMES 'UNICODE'");
             break;
         case 'PDO_MYSQL':
             $db->query("SET NAMES 'utf8'");
             break;
         default:
             break;
     }
     #start up the profiler if needed
     if ($config->setup->database->profiler == true) {
         $db->getProfiler()->setEnabled($config->setup->database->profiler);
     }
     Zend_Db_Table::setDefaultAdapter($db);
     #TODO database driven sessions - maybe we want to change that in future ? for better scaling ?
     Zend_Session::setSaveHandler(new Zend_Session_SaveHandler_DbTable(array('name' => 'session', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'lifetime')));
     //set up the view
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     $viewRenderer->init();
     $view = $viewRenderer->view;
     $view->addHelperPath('Reactor/View/Helper', 'Reactor_View_Helper');
     Zend_Dojo::enableView($view);
     $view->doctype('XHTML1_STRICT');
     $view->setEncoding('UTF-8');
     $view->request = $this->getRequest();
     $view->baseUrl = $this->getRequest()->getBaseUrl();
     $this->locale = new Zend_Locale($config->setup->defaultLocale);
     Zend_Registry::set('Zend_Locale', $this->locale);
     Zend_Translate::setCache(Zend_Registry::get('cache'));
     #TODO currently hardcoded
     Zend_Registry::set('Zend_Translate', new Zend_Translate('gettext', '../data/locales/en_GB/LC_MESSAGES/default.mo', 'en'));
     Zend_Registry::set('Users', new Users());
 }
示例#30
0
 public function _initView()
 {
     $this->bootstrap('layout');
     $layout = $this->getResource('layout');
     $v = $layout->getView();
     $v->addHelperPath(APPLICATION_PATH . "/../library/Core/View/Helper", "Core_View_Helper");
     $config = Zend_Registry::get('config');
     $version = self::getVersion();
     $cache = $this->getPluginResource('cachemanager')->getCacheManager()->getCache('default');
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     Zend_Registry::set('Cache', $cache);
     $this->getResourceLoader()->addResourceType('entity', 'entitys/', 'Entity');
     //Definiendo Constante para Partials
     defined('STATIC_URL') || define('STATIC_URL', $config['app']['staticUrl']);
     defined('DINAMIC_URL') || define('DINAMIC_URL', $config['app']['dinamicUrl']);
     defined('IMG_URL') || define('IMG_URL', $config['app']['imgUrl']);
     defined('SITE_URL') || define('SITE_URL', $config['app']['siteUrl']);
     defined('SITE_TEMP') || define('SITE_TEMP', $config['app']['elementTemp']);
     defined('SITE_VERSION') || define('SITE_VERSION', $version);
     defined('STATIC_ADMIN_IMG') || define('STATIC_ADMIN_IMG', $config['app']['imgAdmin']);
     defined('ROOT_IMG_DINAMIC') || define('ROOT_IMG_DINAMIC', $config['app']['rootImgDinamic']);
     //        defined('LOG_PATH')
     //            || define('LOG_PATH',$config['app']['logPath']);
     //* Antes de modularizar -solo para el landing *//
     //            defined('CHALLENGE_DINAMIC_URL')
     //                || define('CHALLENGE_DINAMIC_URL',$uriChallenge.'/dinamic/');
     ////        }
     //
     $doctypeHelper = new Zend_View_Helper_Doctype();
     $doctypeHelper->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT);
     $v->headTitle($config['resources']['view']['title'])->setSeparator(' | ');
     $v->headMeta()->appendHttpEquiv('Content-Type', 'text/html; charset=utf-8');
     $v->headMeta()->appendName("author", "onlineproduction");
     $v->headMeta()->setName("language", "es");
     $v->headMeta()->appendName("description", "managent aplication");
     $v->headMeta()->appendName("keywords", "ayuda.");
     if (APPLICATION_ENV != 'LOCAL') {
         $this->frontController->throwExceptions(false);
     }
 }