feature #23207 [FrameworkBundle] Allow .yaml file extension everywhere (ogizanagi)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Allow .yaml file extension everywhere

| Q             | A
| ------------- | ---
| Branch?       | 3.4 <!-- see comment below -->
| Bug fix?      | no
| New feature?  | yes <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #23205 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

2940bb0d2c [FrameworkBundle] Allow .yaml file extension everywhere
This commit is contained in:
Fabien Potencier 2017-06-16 11:20:43 -07:00
commit 6727a2610b
3 changed files with 22 additions and 4 deletions

View File

@ -1177,7 +1177,10 @@ class FrameworkExtension extends Extension
foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
$dirname = $bundle['path'];
if ($container->fileExists($file = $dirname.'/Resources/config/validation.yml', false)) {
if (
$container->fileExists($file = $dirname.'/Resources/config/validation.yaml', false) ||
$container->fileExists($file = $dirname.'/Resources/config/validation.yml', false)
) {
$fileRecorder('yml', $file);
}
@ -1385,7 +1388,10 @@ class FrameworkExtension extends Extension
$fileRecorder('xml', $file);
}
if ($container->fileExists($file = $dirname.'/Resources/config/serialization.yml', false)) {
if (
$container->fileExists($file = $dirname.'/Resources/config/serialization.yaml', false) ||
$container->fileExists($file = $dirname.'/Resources/config/serialization.yml', false)
) {
$fileRecorder('yml', $file);
}

View File

@ -33,7 +33,7 @@
</service>
<service id="translation.loader.yml" class="Symfony\Component\Translation\Loader\YamlFileLoader" public="true">
<tag name="translation.loader" alias="yml" />
<tag name="translation.loader" alias="yaml" legacy-alias="yml" />
</service>
<service id="translation.loader.xliff" class="Symfony\Component\Translation\Loader\XliffFileLoader" public="true">
@ -92,6 +92,11 @@
<tag name="translation.dumper" alias="yml" />
</service>
<service id="translation.dumper.yaml" class="Symfony\Component\Translation\Dumper\YamlFileDumper">
<argument>yaml</argument>
<tag name="translation.dumper" alias="yaml" />
</service>
<service id="translation.dumper.qt" class="Symfony\Component\Translation\Dumper\QtFileDumper" public="true">
<tag name="translation.dumper" alias="ts" />
</service>

View File

@ -23,6 +23,13 @@ use Symfony\Component\Translation\Exception\LogicException;
*/
class YamlFileDumper extends FileDumper
{
private $extension;
public function __construct(/**string */$extension = 'yml')
{
$this->extension = $extension;
}
/**
* {@inheritdoc}
*/
@ -50,6 +57,6 @@ class YamlFileDumper extends FileDumper
*/
protected function getExtension()
{
return 'yml';
return $this->extension;
}
}