Skip to content

Commit c009eb8

Browse files
committed
bug #14325 [Routing][DependencyInjection] Support .yaml extension in YAML loaders (thunderer)
This PR was squashed before being merged into the 2.3 branch (closes #14325). Discussion ---------- [Routing][DependencyInjection] Support .yaml extension in YAML loaders | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14319 | License | MIT | Doc PR | - YAML [FAQ](http://www.yaml.org/faq.html) states that .yaml file extension should be used whenever possible. I tweaked YamlFileLoader supports() method in Symfony Routing component to accept both .yml and .yaml and added some asserts in tests for that behavior. This PR replaces #14319 as it was based on 2.7. BTW Is there a way to "rebase" PR branch without redoing all the work? Commits ------- dd5a811 [Routing][DependencyInjection] Support .yaml extension in YAML loaders
2 parents cf5d247 + 7a7703a commit c009eb8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Loader/YamlFileLoader.php

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

8080
/**

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

0 commit comments

Comments
 (0)