Skip to content

Commit 632e934

Browse files
committed
[DI] Allow imports in string format for YAML
1 parent 0bcc5af commit 632e934

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,10 @@ private function parseImports(array $content, $file)
177177
$defaultDirectory = dirname($file);
178178
foreach ($content['imports'] as $import) {
179179
if (!is_array($import)) {
180-
throw new InvalidArgumentException(sprintf('The values in the "imports" key should be arrays in %s. Check your YAML syntax.', $file));
180+
$import = array('resource' => $import);
181+
}
182+
if (!isset($import['resource'])) {
183+
throw new InvalidArgumentException(sprintf('An import should provide a resource in %s. Check your YAML syntax.', $file));
181184
}
182185

183186
$this->setCurrentDir($defaultDirectory);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
imports:
2-
- foo.yml
2+
- { resource: ~ }

src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
imports:
2-
- { resource: services2.yml }
2+
- services2.yml
33
- { resource: services3.yml }
44
- { resource: "../php/simple.php" }
55
- { resource: "../ini/parameters.ini", class: Symfony\Component\DependencyInjection\Loader\IniFileLoader }

0 commit comments

Comments
 (0)