Skip to content

Commit

Permalink
[Routing][DependencyInjection] Support .yaml extension in YAML loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
thunderer authored and Tobion committed Apr 17, 2015
1 parent 8b7148f commit dd5a811
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
Expand Up @@ -73,7 +73,7 @@ public function load($resource, $type = null)
*/
public function supports($resource, $type = null)
{
return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true);
}

/**
Expand Down
Expand Up @@ -187,6 +187,7 @@ public function testSupports()
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());

$this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable');
$this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable');
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Loader/YamlFileLoader.php
Expand Up @@ -104,7 +104,7 @@ public function load($file, $type = null)
*/
public function supports($resource, $type = null)
{
return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'yaml' === $type);
return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type);
}

/**
Expand Down
Expand Up @@ -22,9 +22,11 @@ public function testSupports()
$loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));

$this->assertTrue($loader->supports('foo.yml'), '->supports() returns true if the resource is loadable');
$this->assertTrue($loader->supports('foo.yaml'), '->supports() returns true if the resource is loadable');
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns true if the resource is loadable');

$this->assertTrue($loader->supports('foo.yml', 'yaml'), '->supports() checks the resource type if specified');
$this->assertTrue($loader->supports('foo.yaml', 'yaml'), '->supports() checks the resource type if specified');
$this->assertFalse($loader->supports('foo.yml', 'foo'), '->supports() checks the resource type if specified');
}

Expand Down

0 comments on commit dd5a811

Please sign in to comment.