/** * Load configuration file of options * * @param string $file configuration file * * @throws Zend_Application_Exception When invalid configuration file is provided * * @return array */ protected function _loadConfig($file) { if ($this->isFileUpToDate($file) && ($config = $this->getConfigFromCache())) { return $config; } return $this->storeConfigInCache(parent::_loadConfig($file)); }
/** * Creates and caches Zend_Config. This can't be done in the bootstrap * because the application requires a configuration in order to be * created. * * @param string Config file * @return array */ protected function _loadConfig($file) { $frontendOptions = array( 'automatic_serialization' => true, 'master_file' => $file, 'cache_id_prefix' => APPLICATION_ENV ); if (extension_loaded('apc')) { $cache = Zend_Cache::factory('File', 'Apc', $frontendOptions); } else { $cache = Zend_Cache::factory('File', 'File', $frontendOptions, array( 'cache_dir' => PROJECT_BASE_PATH . '/cache', 'file_locking' => true )); } if (APPLICATION_ENV != 'production' || (!$config = $cache->load('config'))) { $config = parent::_loadConfig($file); // Initialize WordPress configuration values $config = $this->_initWordPress($config); if (APPLICATION_ENV == 'production') { $cache->save($config, 'config'); } } // Save for bootstrapping Zend_Registry::set('config', $obj = new Zend_Config($config)); return $config; }
/** * Load configuration file of options. * * Optionally will cache the configuration. * * @param string $file * @throws Zend_Application_Exception When invalid configuration file is provided * @return array */ protected function _loadConfig($file) { $suffix = pathinfo($file, PATHINFO_EXTENSION); $suffix = $suffix === 'dist' ? pathinfo(basename($file, ".{$suffix}"), PATHINFO_EXTENSION) : $suffix; if ($suffix == 'ini') { $config = Garp_Config_Ini::getCached($file, $this->getEnvironment())->toArray(); } else { $config = parent::_loadConfig($file); } return $config; }
/** * Load configuration file of options. * * Optionally will cache the configuration. * * @param string $file * @throws Zend_Application_Exception When invalid configuration file is provided * @return array */ protected function _loadConfig($file) { if (!$this->_cacheConfig) { return parent::_loadConfig($file); } require_once 'Zend/Cache.php'; $cache = Zend_Cache::factory($this->_cacheOptions['frontendType'], $this->_cacheOptions['backendType'], array_merge(array('master_file' => $file, 'automatic_serialization' => true), $this->_cacheOptions['frontendOptions']), array_merge(array('cache_dir' => APPLICATION_PATH . '/../data/cache'), $this->_cacheOptions['backendOptions'])); $config = $cache->load('Zend_Application_Config'); if (!$config) { $config = parent::_loadConfig($file); $cache->save($config, 'Zend_Application_Config'); } return $config; }
protected function _loadConfig($file) { $filename = str_replace('ini', 'php', basename($file)); $path = APPLICATION_PATH . '/../data/cache/' . $filename; if (file_exists($path)) { return require $path; } $config = parent::_loadConfig($file); if (isset($config['resources']['cachemanager']['default']['active']) && $config['resources']['cachemanager']['default']['active'] || $this->_cacheEnabled) { $this->_cacheEnabled = true; $arrayString = "<?php\n return " . var_export($config, true) . ";\n"; file_put_contents($path, $arrayString); } return $config; }
protected function _loadConfig($file) { if ($this->_useCache == false) { return parent::_loadConfig($file); } $configMTime = filemtime($file); $cacheId = "application_conf_" . md5($file . $this->getEnvironment()); $cacheLastMTime = $this->_configCache->test($cacheId); //Valid cache? if ($cacheLastMTime !== false && $configMTime <= $cacheLastMTime) { return $this->_configCache->load($cacheId, true); } $config = parent::_loadConfig($file); $this->_configCache->save($config, $cacheId, array(), null); return $config; }
/** * Loads the configuration file from either cache or file * * @param string $file * @return array */ protected function _loadConfig($file) { if (isset($this->_cacheOptions['enabled']) && false === $this->_cacheOptions['enabled']) { return parent::_loadConfig($file); } $frontendType = isset($this->_cacheOptions['frontendType']) ? $this->_cacheOptions['frontendType'] : 'File'; $backendType = isset($this->_cacheOptions['backendType']) ? $this->_cacheOptions['backendType'] : 'File'; $frontendOptions = isset($this->_cacheOptions['frontendOptions']) ? $this->_cacheOptions['frontendOptions'] : array(); $backendOptions = isset($this->_cacheOptions['backendOptions']) ? $this->_cacheOptions['backendOptions'] : array(); require_once 'Zend/Cache.php'; $cache = Zend_Cache::factory($frontendType, $backendType, array_merge(array('master_file' => $file, 'automatic_serialization' => true), $frontendOptions), array_merge(array('cache_dir' => sys_get_temp_dir()), $backendOptions)); $config = $cache->load('Zend_Application_Config'); if (!$config) { $config = parent::_loadConfig($file); $cache->save($config, 'Zend_Application_Config'); } return $config; }
/** * @param string $file * @param bool $fromDefault * @return Zend_Config * @author Se# * @version 0.0.1 */ protected function _loadConfig($file, $fromDefault = false) { // define is default config need $default = $fromDefault ? false : $this->_defaultConfig(); $suffix = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if ($this->_configCache === null || $suffix == 'php' || $suffix == 'inc') { //No need for caching those return $default ? $this->_mergeConfigs($default, parent::_loadConfig($file)) : parent::_loadConfig($file); } $configMTime = filemtime($file); $cacheId = $this->_cacheId($file); $cacheLastMTime = $this->_configCache->test($cacheId); if ($cacheLastMTime !== false && $configMTime < $cacheLastMTime) { //Valid cache? return $this->_configCache->load($cacheId, true); } else { $config = parent::_loadConfig($file); $this->_configCache->save($config, $cacheId, array(), null); return $default ? $this->_mergeConfigs($default, $config) : $config; } }