Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d8640f9

Browse files
author
Kevin Grenier
committed
YamlEncoder handle yml extension
1 parent f0168e3 commit d8640f9

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

src/Symfony/Component/Serializer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
-----
66

77
* `AbstractNormalizer::handleCircularReference` is now final, and receives two optional extra arguments: the format and the context
8+
* `YamlEncoder` now handle the `.yml` extension too
89

910
4.1.0
1011
-----

src/Symfony/Component/Serializer/Encoder/YamlEncoder.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
class YamlEncoder implements EncoderInterface, DecoderInterface
2424
{
2525
const FORMAT = 'yaml';
26+
const ALTERNATIVE_FORMAT = 'yml';
2627

2728
private $dumper;
2829
private $parser;
@@ -54,7 +55,7 @@ public function encode($data, $format, array $context = array())
5455
*/
5556
public function supportsEncoding($format)
5657
{
57-
return self::FORMAT === $format;
58+
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
5859
}
5960

6061
/**
@@ -72,6 +73,6 @@ public function decode($data, $format, array $context = array())
7273
*/
7374
public function supportsDecoding($format)
7475
{
75-
return self::FORMAT === $format;
76+
return self::FORMAT === $format || self::ALTERNATIVE_FORMAT === $format;
7677
}
7778
}

src/Symfony/Component/Serializer/Tests/Encoder/YamlEncoderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public function testSupportsEncoding()
3535
$encoder = new YamlEncoder();
3636

3737
$this->assertTrue($encoder->supportsEncoding('yaml'));
38+
$this->assertTrue($encoder->supportsEncoding('yml'));
3839
$this->assertFalse($encoder->supportsEncoding('json'));
3940
}
4041

@@ -51,6 +52,7 @@ public function testSupportsDecoding()
5152
$encoder = new YamlEncoder();
5253

5354
$this->assertTrue($encoder->supportsDecoding('yaml'));
55+
$this->assertTrue($encoder->supportsDecoding('yml'));
5456
$this->assertFalse($encoder->supportsDecoding('json'));
5557
}
5658

0 commit comments

Comments
 (0)