Skip to content

Commit dd5a811

Browse files
thundererTobion
authored andcommitted
[Routing][DependencyInjection] Support .yaml extension in YAML loaders
1 parent 8b7148f commit dd5a811

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function load($resource, $type = null)
7373
*/
7474
public function supports($resource, $type = null)
7575
{
76-
return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION);
76+
return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true);
7777
}
7878

7979
/**

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ public function testSupports()
187187
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());
188188

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function load($file, $type = null)
104104
*/
105105
public function supports($resource, $type = null)
106106
{
107-
return is_string($resource) && 'yml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'yaml' === $type);
107+
return is_string($resource) && in_array(pathinfo($resource, PATHINFO_EXTENSION), array('yml', 'yaml'), true) && (!$type || 'yaml' === $type);
108108
}
109109

110110
/**

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ public function testSupports()
2222
$loader = new YamlFileLoader($this->getMock('Symfony\Component\Config\FileLocator'));
2323

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

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

0 commit comments

Comments
 (0)