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 static function loadFileXml(File $file) { libxml_use_internal_errors(true); $data = simplexml_load_file($file->absolute(), null, LIBXML_NOERROR); if ($data === false) { $errors = libxml_get_errors(); $latestError = array_pop($errors); throw new \Exception($latestError->message, $latestError->code); } return json_decode(json_encode($data), true); }
private function cacheSphringBean() { $origFile = new File($this->sphring->getYamlarh()->getFilename()); $cacheFileBean = new File(sys_get_temp_dir() . DIRECTORY_SEPARATOR . SphringCacheEnum::CACHE_FOLDER . DIRECTORY_SEPARATOR . sprintf(SphringCacheEnum::CACHE_FILE_BEAN, $origFile->getHash('md5'))); if (!$this->cacheManager->isCacheSphringBean()) { if ($cacheFileBean->isFile()) { $cacheFileBean->remove(); } return; } $origFile = new File($this->sphring->getYamlarh()->getFilename()); if ($cacheFileBean->isFile() && $origFile->getTime() == $cacheFileBean->getTime()) { return; } $beans = $this->sphring->getBeansObject(); $origFile = $this->sphring->getYamlarh()->getFilename(); $time = $this->getTime(); touch($origFile, $time); $cacheFileBean->setContent(serialize($beans)); touch($cacheFileBean->absolute(), $time); }
/** * @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)); }