/** * @param string $type */ public function create() { /* @var $userConfig Zend\Tool\Framework\Client\Config */ $userConfig = $this->_registry->getConfig(); $resp = $this->_registry->getResponse(); if ($userConfig->exists()) { throw new Exception\RuntimeException('A configuration already exists; cannot create a new one'); } $homeDirectory = $this->_detectHomeDirectory(); $writer = new IniConfigWriter(); $writer->setRenderWithoutSections(); $filename = $homeDirectory . '/.zf.ini'; $config = array('php' => array('include_path' => get_include_path())); $writer->write($filename, new Configuration($config)); $resp = $this->_registry->getResponse(); $resp->appendContent("Successfully written Zend Tool config."); $resp->appendContent("It is located at: " . $filename); }
public function testRenderWithoutSections2() { $config = new IniConfig(__DIR__ . '/files/allsections.ini', null, array('skipExtends' => true)); $writer = new 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); }
/** * Get the config writer that corresponds to the current config file type. * * @return ConfigWriter\AbstractFileWriter */ protected function getConfigWriter() { $suffix = substr($this->getConfigFilepath(), -4); switch ($suffix) { case '.ini': $writer = new ConfigWriter\Ini(); $writer->setRenderWithoutSections(); break; case '.xml': $writer = new ConfigWriter\Xml(); break; case '.php': $writer = new ConfigWriter\ArrayWriter(); break; default: throw new Exception\RuntimeException(sprintf('Unknown config file type "%s" at location "%s"', $suffix, $this->getConfigFilepath())); } return $writer; }