/** * @param string $type */ public function create() { /* @var $userConfig Zend_Tool_Framework_Client_Config */ $userConfig = $this->_registry->getConfig(); $resp = $this->_registry->getResponse(); if ($userConfig->exists()) { require_once "Zend/Tool/Framework/Exception.php"; throw new Zend_Tool_Framework_Exception( "A configuration already exists, cannot create a new one."); } $homeDirectory = $this->_detectHomeDirectory(); $writer = new Zend_Config_Writer_Ini(); $writer->setRenderWithoutSections(); $filename = $homeDirectory."/.zf.ini"; $config = array( 'php' => array( 'include_path' => get_include_path(), ), ); $writer->write($filename, new Zend_Config($config)); $resp = $this->_registry->getResponse(); $resp->appendContent("Successfully written Zend Tool config."); $resp->appendContent("It is located at: ".$filename); }
/** * Get the config writer that corresponds to the current config file type. * * @return Zend_Config_Writer_FileAbstract */ protected function getConfigWriter() { $suffix = substr($this->getConfigFilepath(), -4); switch ($suffix) { case '.ini': // require_once "Zend/Config/Writer/Ini.php"; $writer = new Zend_Config_Writer_Ini(); $writer->setRenderWithoutSections(); break; case '.xml': // require_once "Zend/Config/Writer/Xml.php"; $writer = new Zend_Config_Writer_Xml(); break; case '.php': // require_once "Zend/Config/Writer/Array.php"; $writer = new Zend_Config_Writer_Array(); break; default: // require_once 'Zend/Tool/Framework/Client/Exception.php'; throw new Zend_Tool_Framework_Client_Exception('Unknown config file type ' . $suffix . ' at location ' . $this->getConfigFilepath()); } return $writer; }
public function testRenderWithoutSections2() { $config = new Zend_Config_Ini(dirname(__FILE__) . '/files/allsections.ini', null, array('skipExtends' => true)); $writer = new Zend_Config_Writer_Ini(); $writer->setRenderWithoutSections(); $iniString = $writer->setConfig($config)->render(); $expected = <<<ECS all.hostname = "all" all.name = "thisname" all.db.host = "127.0.0.1" all.db.user = "******" all.db.pass = "******" all.db.name = "live" all.one.two.three = "multi" staging.hostname = "staging" staging.db.name = "dbstaging" staging.debug = "" debug.hostname = "debug" debug.debug = "1" debug.values.changed = "1" debug.db.name = "dbdebug" debug.special.no = "" debug.special.null = "" debug.special.false = "" other_staging.only_in = "otherStaging" other_staging.db.pass = "******" ECS; $this->assertEquals($expected, $iniString); }
/** * For now only contains the database source environment, but can be used to add more * configuration that's needed at restore time. * * @return void */ public function addSettingsFile() { $config = new Zend_Config(array(), true); $config->gumball = array(); $config->gumball->sourceDbEnvironment = $this->_dbEnv; $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $this->_getTargetDirectoryPath() . '/application/configs/gumball.ini')); $writer->setRenderWithoutSections(); $writer->write(); }