/** * @param $pathToSave Путь к файлу в котором будет сохранен конфиг приложения. */ protected function _saveCache($pathToSave) { $writer = new Zend_Config_Writer_Array(); $options = $this->getOptions(); if (array_key_exists('config', $options)) { unset($options['config']); } $writer->setConfig(new Zend_Config($options)); try { $writer->write($pathToSave); } catch (Zend_Config_Exception $exception) { return; } }
/** * @group ZF-8234 */ public function testRender() { $config = new Zend_Config(array('test' => 'foo', 'bar' => array(0 => 'baz', 1 => 'foo'))); $writer = new Zend_Config_Writer_Array(); $configString = $writer->setConfig($config)->render(); // build string line by line as we are trailing-whitespace sensitive. $expected = "<?php\n"; $expected .= "return array (\n"; $expected .= " 'test' => 'foo',\n"; $expected .= " 'bar' => \n"; $expected .= " array (\n"; $expected .= " 0 => 'baz',\n"; $expected .= " 1 => 'foo',\n"; $expected .= " ),\n"; $expected .= ");\n"; $this->assertEquals($expected, $configString); }
/** * Create cached version of navigation translations file for the give file and locale * * @param string $filepath Navigation translation file path Filepath * @param string $locale Locale * @param string $userLevel User level for which the file is created * @throws Zend_Config_Exception * @throws iMSCP_Exception */ function layout_createNavigationFile($filepath, $locale, $userLevel) { $translationsCacheDir = CACHE_PATH . '/translations/navigation'; if (!is_dir($translationsCacheDir)) { if (!@mkdir($translationsCacheDir)) { throw new iMSCP_Exception('Unable to create cache directory for navigation translations'); } } $config = new Zend_Config(include $filepath); $writter = new Zend_Config_Writer_Array(); $writter->setConfig($config); $writter->write($translationsCacheDir . '/' . $userLevel . '_' . $locale . '.php'); }