Example #1
0
 /**
  * @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 RuntimeException("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($config));
     $resp = $this->_registry->getResponse();
     $resp->appendContent("Successfully written Zend Tool config.");
     $resp->appendContent("It is located at: " . $filename);
 }
Example #2
0
 /**
  * Get the config writer that corresponds to the current config file type.
  *
  * @return \Zend\Config\Writer\AbstractFileWriter
  */
 protected function getConfigWriter()
 {
     $suffix = substr($this->getConfigFilepath(), -4);
     switch ($suffix) {
         case '.ini':
             $writer = new \Zend\Config\Writer\Ini();
             $writer->setRenderWithoutSections();
             break;
         case '.xml':
             $writer = new \Zend\Config\Writer\Xml();
             break;
         case '.php':
             $writer = new \Zend\Config\Writer\ArrayWriter();
             break;
         default:
             throw new Exception('Unknown config file type ' . $suffix . ' at location ' . $this->getConfigFilepath());
     }
     return $writer;
 }