/** * {@inheritdoc} */ public function __construct($filepath) { parent::__construct($filepath); if (!class_exists('Spyc')) { throw new RuntimeException('Spyc library must be installed.'); } }
/** * {@inheritdoc} */ public function resolveImports(LoaderInterface $loader) { $filepath = $loader->getFilepath(); if (isset($this->data['imports']['files'])) { if (isset($this->metadata[$filepath]['imports']['files'])) { $removed = array_diff($this->metadata[$filepath]['imports']['files'], $this->data['imports']['files']); $added = array_diff($this->data['imports']['files'], $this->metadata[$filepath]['imports']['files']); $this->removeConfig($loader, $removed); foreach ($added as $path) { if ($key = array_search($path, $this->data['imports']['files']) !== false) { unset($this->data['imports']['files'][$key]); unset($this->metadata[$path]); } } } $loaders = []; foreach ($this->data['imports']['files'] as $file) { $path = $this->createFilepath($loader, $file); if (is_file($path) === false) { throw new RuntimeException('Imported config file "' . $path . '" does not exists.'); } $loaders[] = BaseLoader::factory($path)->setParentFilepath($filepath); } unset($this->data['imports']); /** * First we create loaders, and after remove imports, append these loaders * to object. This prevent recursion loop. */ foreach ($loaders as $loader) { $this->appendFromLoader($loader); } } else { if (isset($this->metadata[$filepath]['imports']['files'])) { foreach ($this->metadata[$filepath]['imports']['files'] as $file) { $path = $this->createFilepath($loader, $file); if (isset($this->metadata[$path])) { $this->removeIndexes($this->metadata[$path]['indexes']); unset($this->metadata[$path]); } } } } return $this; }
/** * Constructor. * @param string $filepath Configuration filepath to parse. * @param boolean $parseSections Parser should parse INI sections? */ public function __construct($filepath, $parseSections = true) { $this->parseSections = $parseSections; parent::__construct($filepath); }