Ejemplo n.º 1
0
 /**
  * Transform an XML file to array
  * @param string $xmlFile
  * @return type
  */
 protected function xmlToArray($xmlFile)
 {
     $data = FALSE;
     if (file_exists($xmlFile)) {
         $reader = new \Zend\Config\Reader\Xml();
         $xml = $reader->fromFile($xmlFile);
         if ($xml) {
             $data = $xml;
         }
     }
     return $data;
 }
Ejemplo n.º 2
0
 /**
  * Read an XML File and return it as an array
  * @param string $xml Path to XML File
  * @return array|boolean 
  */
 public static function toArray($xmlFile)
 {
     $data = FALSE;
     if (file_exists($xmlFile)) {
         $reader = new \Zend\Config\Reader\Xml();
         $xml = $reader->fromFile($xmlFile);
         if ($xml) {
             $cacheObj = self::getCache();
             $data = $xml;
         }
     }
     return $data;
 }
Ejemplo n.º 3
0
 public function index3Action()
 {
     $reader = new \Zend\Config\Reader\Xml();
     $data = $reader->fromFile(__DIR__ . '/../../../config/xml/module.config.xml');
     echo "<pre>";
     print_r($data);
     echo "</pre>";
     /** ghi vao file xml */
     $config = new \Zend\Config\Config(array(), true);
     $config->production = array();
     $config->production->website = 'zend.vn';
     $config->production->account = array();
     $config->production->account->email = '*****@*****.**';
     $config->production->account->port = 465;
     $writer = new \Zend\Config\Writer\Xml();
     $writer->toFile(__DIR__ . '/../../../config/xml/config.xml', $config);
     return false;
 }
Ejemplo n.º 4
0
 public function getConfig()
 {
     /*
             Read file config by xml
     */
     $reader = new \Zend\Config\Reader\Xml();
     // $reader->setNestSeparator(".");
     $configArr = $reader->fromFile(__DIR__ . "/config/module.config.xml");
     $configArr['view_manager']['template_path_stack'] = array(__DIR__ . "/view");
     foreach ($configArr['controllers']['invokables'] as $key => $value) {
         $newKey = preg_replace("#Controller\$#", "", $value);
         $configArr['controllers']['invokables'][$newKey] = $value;
         unset($configArr['controllers']['invokables'][$key]);
     }
     /*
             Read file config by ini
     */
     // $reader = new \Zend\Config\Reader\Ini();
     // $reader->setNestSeparator(".");
     // $configArr = $reader->fromFile(__DIR__."/config/module.config.ini");
     // $configArr['view_manager']['template_path_stack'] = array(__DIR__."/view");
     //return $configArr;
     return include __DIR__ . '/config/module.config.php';
 }