8000 bug #10545 [DependencyInjection] Fixed YamlFileLoader imports path (j… · webmozart/symfony@e4ff8ae · GitHub
[go: up one dir, main page]

Skip to content

Commit e4ff8ae

Browse files
committed
bug symfony#10545 [DependencyInjection] Fixed YamlFileLoader imports path (jrnickell)
This PR was merged into the 2.3 branch. Discussion ---------- [DependencyInjection] Fixed YamlFileLoader imports path | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#10516 | License | MIT | Doc PR | http://symfony.com/doc/current/book/service_container.html#importing-configuration-with-imports YamlFileLoader used the resource name as the current directory during import, which can cause a failed import when using a relative path. Using the $path variable output from the locator is consistent with other loaders and fixes the bug. Commits ------- fd1d48b Fixed YamlFileLoader imports path
2 parents 58f5f4a + fd1d48b commit e4ff8ae

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function load($file, $type = null)
5151
}
5252

5353
// imports
54-
$this->parseImports($content, $file);
54+
$this->parseImports($content, $path);
5555

5656
// parameters
5757
if (isset($content['parameters'])) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
imports:
22
- { resource: services2.yml }
33
- { resource: services3.yml }
4+
- { resource: "../php/simple.php" }
45
- { resource: "../ini/parameters.ini", class: Symfony\Component\DependencyInjection\Loader\IniFileLoader }
56
- { resource: "../ini/parameters2.ini" }
67
- { resource: "../xml/services13.xml" }

src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
1919
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
2020
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
21+
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
2122
use Symfony\Component\Config\Loader\LoaderResolver;
2223
use Symfony\Component\Config\FileLocator;
2324

@@ -93,6 +94,7 @@ public function testLoadImports()
9394
$resolver = new LoaderResolver(array(
9495
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
9596
new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
97+
new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')),
9698
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
9799
));
98100
$loader->setResolver($resolver);

0 commit comments

Comments
 (0)
0