Example #1
0
 private function searchForInclude(&$arrayYaml = null)
 {
     if (empty($arrayYaml)) {
         $arrayYaml = $this->yamlarh->getArrayToReturn();
     }
     $includeYaml = null;
     foreach ($arrayYaml as $key => $value) {
         if (is_array($value) && $key !== $this->yamlarh->getParamaterKey() . $this->nodeName && count($value) > 0) {
             $includeYaml[$key] = $this->searchForInclude($value);
             continue;
         }
         if ($key !== $this->yamlarh->getParamaterKey() . $this->nodeName) {
             $includeYaml[$key] = $value;
             continue;
         }
         if (!is_array($value)) {
             $value = array($value);
         }
         $includeYaml = array();
         foreach ($value as $includeFile) {
             $currentFile = new File($this->yamlarh->getFilename());
             $includeFile = new File($includeFile);
             if (!$includeFile->isFile()) {
                 $includeFile->setFolder($currentFile->getFolder() . $includeFile->getFolder());
             }
             $yamlArh = $this->getNewYamlarh($includeFile->absolute());
             $includeYaml = array_merge($yamlArh->parse(), $arrayYaml, $includeYaml);
         }
         unset($includeYaml[$this->yamlarh->getParamaterKey() . $this->nodeName]);
     }
     return $includeYaml;
 }
 private function loadFromFile($filename)
 {
     $currentFile = new File($this->yamlarh->getFilename());
     $file = new File($filename);
     if (!$file->isFile()) {
         $file->setFolder($currentFile->getFolder() . $file->getFolder());
     }
     if (!$file->isFile()) {
         throw new SphringException("Property file '%s' cannot be found.", $file->getName());
     }
     $properties = FileLoader::loadFile($file);
     if ($properties === null && in_array($file->getExtension(), self::$extIni)) {
         $ini = new \Zend_Config_Ini($file->absolute());
         $properties = $ini->toArray();
     } elseif ($properties === null) {
         return;
     }
     $this->injectInYamlarh($properties);
 }
Example #3
0
 /**
  * @param $fileName
  * @param File $file
  * @throws \Exception
  */
 private function getFromImport($fileName, File $file)
 {
     if (is_file($fileName)) {
         $fileFinalName = $fileName;
     } else {
         $fileFinalName = $file->getFolder() . '/' . $fileName;
     }
     $fileTmp = new File($fileFinalName);
     if (!$fileTmp->isFile()) {
         $fileFinalName = $file->getFolder() . '/' . $fileName;
     }
     if (!is_file($fileFinalName)) {
         throw new \Exception("The yml file " . $file->absolute() . " can't found yml file " . $fileName . " for import");
     }
     $this->parseFile(new File($fileFinalName));
 }