Skip to content

Commit

Permalink
Fixed YamlFileLoader imports path
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrnickell authored and fabpot committed Mar 27, 2014
1 parent 58f5f4a commit fd1d48b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
Expand Up @@ -51,7 +51,7 @@ public function load($file, $type = null)
}

// imports
$this->parseImports($content, $file);
$this->parseImports($content, $path);

// parameters
if (isset($content['parameters'])) {
Expand Down
@@ -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" }
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit fd1d48b

Please sign in to comment.