/** * Get options * * @return array */ private function _getOptions() { if (!extension_loaded('apc')) { return $this->_makeOptions(); } //@todo GET SESSION/CACHE/LOAD Config include_once 'ZLayer/Cache.php'; include_once 'Zend/Cache.php'; include_once 'Zend/Cache/Core.php'; include_once 'Zend/Cache/Backend/Apc.php'; $configCache = new Zend_Cache_Core(array('automatic_serialization' => true)); $backend = new Zend_Cache_Backend_Apc(); $configCache->setBackend($backend); //$configMTime = filemtime($file); $cacheId = ZLayer_Cache::id("application"); $configCache->remove($cacheId); if ($configCache->test($cacheId) !== false) { return $configCache->load($cacheId, true); } else { $array = $this->_makeOptions(); $configCache->save($array, $cacheId, array(), null); return $array; } }
/** * Initialize Front Controller * */ public function init() { $resOptions = $this->getOptions(); $this->_basePath = $resOptions["basePath"]; $cacheId = ZLayer_Cache::id("theme"); if ($requestCache = ZLayer_Cache::get('theme')) { if ($requestCache->test($cacheId) !== false) { $optionsAr = $requestCache->load($cacheId, true); } else { $optionsAr = $this->_getThemesOptions($resOptions["name"]); $requestCache->save($optionsAr, $cacheId, array(), null); } } else { $optionsAr = $this->_getThemesOptions($resOptions["name"]); } if (!isset($optionsAr["resources"])) { return; } $bootstrap = $this->getBootstrap(); $resAr = $optionsAr["resources"]; $bootstrap = $this->getBootstrap(); $bootOptionsAr = $bootstrap->getOptions(); foreach ($resAr as $resKey => $resValue) { if (isset($bootOptionsAr["resources"][$resKey])) { $bootResOptionsAr = $bootOptionsAr["resources"][$resKey]; if (is_array($bootResOptionsAr)) { $resValue = array_merge_recursive($bootResOptionsAr, $resValue); } } $resource = $bootstrap->getPluginResource($resKey); $resource->setOptions($resValue); if ($resKey != "theme") { $bootstrap->bootstrap(ucfirst($resKey)); } } }
/** * _getFileOptions * * @param string $file * @param string $baseDir * @return array|bool */ private function _getFileOptions($file, $baseDir) { if ($fileCache = $requestCache = ZLayer_Cache::get('request')) { $cacheId = ZLayer_Cache::id("request_file_" . $baseDir . $file); if ($fileCache->test($cacheId) !== false) { return $fileCache->load($cacheId, true); } else { $array = $this->_makeFileOptions($file, $baseDir); $fileCache->save($array, $cacheId, array(), null); return $array; } } else { return $this->_makeFileOptions($file, $baseDir); } }
/** * Get options * * @return Zend_Config */ protected function _getOptions() { if ($formCache = ZLayer_Cache::get('form')) { $cacheId = ZLayer_Cache::id('form_dojo_' . $this->_module . $this->_form); if ($formCache->test($cacheId) !== false) { $this->_options = $formCache->load($cacheId, true); return $this->_options; } else { $this->_makeDojoOptions(); $formCache->save($this->_options, $cacheId, array(), null); return $this->_options; } } else { $this->_makeDojoOptions(); return $this->_options; } }