public function __construct($debug, $filename, $rundir) { parent::__construct($debug, $filename, $rundir); try { $content = Yaml::parse($this->fileData); // Look for imports if (isset($content['imports']) && is_array($content['imports'])) { // Imports are defined relatively, get the directory based on the current file $currentPathInfo = pathinfo($filename); $dirname = $currentPathInfo['dirname']; foreach ($content['imports'] as $import) { if (isset($import['resource'])) { $importYmlFileName = $dirname . '/' . $import['resource']; $importYmlFile = new YmlFile($debug, $importYmlFileName, $rundir); $extraContent = $importYmlFile->getYaml(); // Imports are at the top of the yaml file, so these should be loaded first. // The values of the current yaml file will overwrite existing array values of the imports. $content = array_replace_recursive($extraContent, $content); } } } $this->yamlFile = $content; } catch (ParseException $ex) { throw new FileLoadException("Parsing yaml file ({$filename}) failed: " . $ex->getMessage()); } }
public function __construct($debug, $filename, $rundir) { parent::__construct($debug, $filename, $rundir); $this->json = json_decode($this->fileData, true); }