Skip to content

Commit

Permalink
feature #22176 [DI] Allow imports in string format for YAML (ro0NL)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Allow imports in string format for YAML

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

I see no real reasons why this shouldnt be allowed..

Before

```yml
imports:
    - { resource: config.yml }
```

After

```yml
imports:
    - config.yml
```

Commits
-------

632e934 [DI] Allow imports in string format for YAML
  • Loading branch information
fabpot committed Jul 11, 2017
2 parents 050d686 + 632e934 commit f9d73b9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Expand Up @@ -177,7 +177,10 @@ private function parseImports(array $content, $file)
$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);
Expand Down
@@ -1,2 +1,2 @@
imports:
- foo.yml
- { resource: ~ }
@@ -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 }
Expand Down

0 comments on commit f9d73b9

Please sign in to comment.