Beispiel #1
0
 /**
  * Склеивает все файлы в единый конфиг, попутно задействуя кеш
  *
  * @param string $path Путь к папке с файлами
  * @param string $env APPLICATION_ENV
  * @return array
  */
 public static function load($path, $env)
 {
     $masterfiles = array();
     if (file_exists($path . 'application.xml')) {
         $handler = opendir($path);
         while (($file = readdir($handler)) !== false) {
             if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'xml') {
                 $masterfiles[] = $path . $file;
             }
         }
         sort($masterfiles);
         closedir($handler);
         $cache = self::getCache($masterfiles);
         $cacheid = md5($path);
         if ($cache->test($cacheid)) {
             return $cache->load($cacheid);
         } else {
             $config = new Zend_Config_Xml($path . 'application.xml', $env, array('allowModifications' => true));
             foreach ($masterfiles as $file) {
                 if ($file != 'application.xml') {
                     $config->merge(new Zend_Config_Xml($file, $env));
                 }
             }
             $config = $config->toArray();
             $cache->save($config, $cacheid);
             return $config;
         }
     }
     return false;
 }
 private function _loadConfig()
 {
     $coreConfig = new Zend_Config_Xml($this->dir . 'configs/core.xml', 'core', true);
     if ($coreConfig->mode == 'staging') {
         $config = new Zend_Config_Xml($this->dir . 'configs/core.xml', $coreConfig->mode, true);
         $config->merge($coreConfig);
     } else {
         /*	załadowanie konfigiracji z cache'a	*/
         if (!($config = $this->_cache->load('config'))) {
             $config = new Zend_Config_Xml($this->dir . 'configs/core.xml', $coreConfig->mode, true);
             $config->merge($coreConfig);
             $this->_cache->save($config, 'config', array('config'));
         }
     }
     $this->_config = $config;
     $this->_config->serviceDir = substr(__FILE__, 0, strpos(__FILE__, 'core' . DIRECTORY_SEPARATOR . 'Bootstrap.php'));
     Zend_Registry::set('config', $this->_config);
 }
Beispiel #3
0
 /**
  * get config options as Zend_Config_Xml object
  *
  * @param Tinebase_Model_ImportExportDefinition $_definition
  * @param array $_additionalOptions additional options
  * @return Zend_Config_Xml
  */
 public static function getOptionsAsZendConfigXml(Tinebase_Model_ImportExportDefinition $_definition, $_additionalOptions = array())
 {
     $tmpfname = tempnam(Tinebase_Core::getTempDir(), "tine_tempfile_");
     if (!$tmpfname) {
         throw new Tinebase_Exception_AccessDenied('Could not create temporary file.');
     }
     $handle = fopen($tmpfname, "w");
     fwrite($handle, $_definition->plugin_options);
     fclose($handle);
     // read file with Zend_Config_Xml
     $config = new Zend_Config_Xml($tmpfname, null, TRUE);
     $config->merge(new Zend_Config($_additionalOptions));
     unlink($tmpfname);
     return $config;
 }