Ejemplo n.º 1
0
 /**
  * @return array
  *
  * @throws ParsingException
  */
 public function parse()
 {
     try {
         $parser = new \Zend_Config_Yaml($this->getFile());
     } catch (\Zend_Config_Exception $e) {
         throw new ParsingException("Cannot parse this file: " . $e->getMessage(), 0, $e);
     }
     return $parser->toArray();
 }
Ejemplo n.º 2
0
 protected function _processFile($globalFile, $localFile = null)
 {
     if (!file_exists($globalFile)) {
         throw new Mage_Core_Exception("Cannot find global configuration YAML file.");
     }
     // Decode the YAML File
     $globalClass = new Zend_Config_Yaml($globalFile, NULL, array('ignore_constants' => true));
     $globalArray = $globalClass->toArray();
     return $globalArray;
 }
Ejemplo n.º 3
0
 protected function _processFile($globalFile, $localFile = null)
 {
     if (!file_exists($globalFile)) {
         $this->log("No configuration component found in: " . $globalFile);
         $this->log("Skipping");
         throw new Mage_Core_Exception("Cannot find global configuration YAML file.");
     }
     // Decode the YAML File
     $globalClass = new Zend_Config_Yaml($globalFile, NULL, array('ignore_constants' => true));
     $globalArray = $globalClass->toArray();
     $localArray = array();
     if (file_exists($localFile)) {
         // Decode the YAML File
         $localClass = new Zend_Config_Yaml($localFile, NULL, array('ignore_constants' => true));
         $localArray = $localClass->toArray();
     }
     $data = array_merge_recursive($globalArray, $localArray);
     return $data;
 }
Ejemplo n.º 4
0
 public function testWriteAndReadOriginalFile()
 {
     $config = new Zend_Config_Yaml(dirname(__FILE__) . '/files/allsections.yaml', null, array('skip_extends' => true));
     $writer = new Zend_Config_Writer_Yaml(array('config' => $config, 'filename' => $this->_tempName));
     $writer->write();
     $config = new Zend_Config_Yaml($this->_tempName, null);
     $this->assertEquals('multi', $config->staging->one->two->three, var_export($config->toArray(), 1));
     $config = new Zend_Config_Yaml($this->_tempName, null, array('skip_extends' => true));
     $this->assertFalse(isset($config->staging->one));
 }