[DI] Allow imports in string format for YAML

This commit is contained in:
Roland Franssen 2017-03-27 16:07:30 +02:00
parent 0bcc5afbda
commit 632e934cfa
3 changed files with 6 additions and 3 deletions

View File

@ -177,7 +177,10 @@ class YamlFileLoader extends FileLoader
$defaultDirectory = dirname($file);
foreach ($content['imports'] as $import) {
if (!is_array($import)) {
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
$import = array('resource' => $import);
}
if (!isset($import['resource'])) {
throw new InvalidArgumentException(sprintf('An import should provide a resource in %s. Check your YAML syntax.', $file));
}
$this->setCurrentDir($defaultDirectory);

View File

@ -1,2 +1,2 @@
imports:
- foo.yml
- { resource: ~ }

View File

@ -1,5 +1,5 @@
imports:
- { resource: services2.yml }
- services2.yml
- { resource: services3.yml }
- { resource: "../php/simple.php" }
- { resource: "../ini/parameters.ini", class: Symfony\Component\DependencyInjection\Loader\IniFileLoader }