bug #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 | #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
This commit is contained in:
commit
e4ff8ae22f
@ -51,7 +51,7 @@ class YamlFileLoader extends FileLoader
|
||||
}
|
||||
|
||||
// imports
|
||||
$this->parseImports($content, $file);
|
||||
$this->parseImports($content, $path);
|
||||
|
||||
// parameters
|
||||
if (isset($content['parameters'])) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
imports:
|
||||
- { resource: services2.yml }
|
||||
- { resource: services3.yml }
|
||||
- { resource: "../php/simple.php" }
|
||||
- { resource: "../ini/parameters.ini", class: Symfony\Component\DependencyInjection\Loader\IniFileLoader }
|
||||
- { resource: "../ini/parameters2.ini" }
|
||||
- { resource: "../xml/services13.xml" }
|
||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Config\Loader\Loader;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
|
||||
@ -93,6 +94,7 @@ class YamlFileLoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$resolver = new LoaderResolver(array(
|
||||
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
|
||||
new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
|
||||
new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')),
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
|
||||
));
|
||||
$loader->setResolver($resolver);
|
||||
|
Reference in New Issue
Block a user