public function __construct(array $files = null)
{
$files = is_null($files) ? $this->findAllConfigurationFiles() : $files;
if (count($files) == 0) {
throw new \StackFormation\Exception\NoBlueprintsFoundException("Could not find any blueprints.yml configuration files");
}
$yamlParser = new \Symfony\Component\Yaml\Parser();
$config = [];
$stacknames = [];
foreach ($files as $file) {
$basePath = dirname(realpath($file));
$tmp = $yamlParser->parse(file_get_contents($file));
if (isset($tmp['blueprints']) && is_array($tmp['blueprints'])) {
foreach ($tmp['blueprints'] as &$blueprintConfig) {
// check for multiple usage of the same stackname
$stackname = $blueprintConfig['stackname'];
if (in_array($stackname, $stacknames)) {
throw new \Exception("Stackname '{$stackname}' was declared more than once.");
}
if (empty($blueprintConfig['template'])) {
throw new \Exception("Stackname '{$stackname}' does not specify a template.");
}
$stacknames[] = $stackname;
$blueprintConfig['basepath'] = $basePath;
}
}
$config[] = $tmp;
}
$processor = new \Symfony\Component\Config\Definition\Processor();
$this->conf = $processor->processConfiguration(new ConfigTreeBuilder(), $config);
}