From fd1d48b54f99c71bfb8db9a9028f72daa11837a7 Mon Sep 17 00:00:00 2001 From: John Nickell Date: Thu, 27 Mar 2014 01:16:27 -0500 Subject: [PATCH] Fixed YamlFileLoader imports path 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. --- .../Component/DependencyInjection/Loader/YamlFileLoader.php | 2 +- .../DependencyInjection/Tests/Fixtures/yaml/services4.yml | 1 + .../DependencyInjection/Tests/Loader/YamlFileLoaderTest.php | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php index ce135fa81f92..21c706fc59e7 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php @@ -51,7 +51,7 @@ public function load($file, $type = null) } // imports - $this->parseImports($content, $file); + $this->parseImports($content, $path); // parameters if (isset($content['parameters'])) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml index 18f10658c437..8e0987fd03a6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services4.yml @@ -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" } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index 85ac9e3a97cd..008a6c591fad 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -18,6 +18,7 @@ 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 @@ public function testLoadImports() $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);