Skip to content

Commit 49d11ac

Browse files
committed
Merge branch '3.1'
* 3.1: [TwigBridge] fix tests Tag the FormFieldRegistry as being internal [Form] Fix Date\TimeType marked as invalid on request with single_text and zero seconds [FrameworkBundle] Register the ArrayDenormalizer [Serializer] Fix DataUriNormalizer's regex [Validator] Added missing swedish translation [TranslationDebug] workaround for getFallbackLocales. [Translation] fixed nested fallback catalogue using multiple locales. fixed phpdoc [Command] Fixed method comments as phpDoc syntax Added single quotes for upgrade guides.
2 parents fed2ea7 + ff62c1e commit 49d11ac

File tree

5 files changed

+89
-2
lines changed

5 files changed

+89
-2
lines changed

Command/TranslationDebugCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
use Symfony\Component\Translation\Catalogue\MergeOperation;
2222
use Symfony\Component\Translation\MessageCatalogue;
2323
use Symfony\Component\Translation\Translator;
24+
use Symfony\Component\Translation\DataCollectorTranslator;
25+
use Symfony\Component\Translation\LoggingTranslator;
2426

2527
/**
2628
* Helps finding unused or missing translation messages in a given locale
@@ -307,7 +309,7 @@ private function loadFallbackCatalogues($locale, $transPaths, TranslationLoader
307309
{
308310
$fallbackCatalogues = array();
309311
$translator = $this->getContainer()->get('translator');
310-
if ($translator instanceof Translator) {
312+
if ($translator instanceof Translator || $translator instanceof DataCollectorTranslator || $translator instanceof LoggingTranslator) {
311313
foreach ($translator->getFallbackLocales() as $fallbackLocale) {
312314
if ($fallbackLocale === $locale) {
313315
continue;

Resources/config/serializer.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@
2424
<argument type="service" id="serializer.property_accessor" />
2525
<argument type="service" id="property_info" on-invalid="ignore" />
2626

27-
<!-- Run after all custom serializers -->
27+
<!-- Run after all custom normalizers -->
2828
<tag name="serializer.normalizer" priority="-1000" />
2929
</service>
3030

31+
<service id="serializer.denormalizer.array" class="Symfony\Component\Serializer\Normalizer\ArrayDenormalizer" public="false">
32+
<!-- Run before the object normalizer -->
33+
<tag name="serializer.normalizer" priority="-990" />
34+
</service>
35+
3136
<!-- Loader -->
3237
<service id="serializer.mapping.chain_loader" class="Symfony\Component\Serializer\Mapping\Loader\LoaderChain" public="false">
3338
<argument type="collection" />

Tests/Functional/SerializerTest.php

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
13+
14+
use Symfony\Component\Serializer\Normalizer\DataUriNormalizer;
15+
16+
/**
17+
* @author Kévin Dunglas <dunglas@gmail.com>
18+
*/
19+
class SerializerTest extends WebTestCase
20+
{
21+
public function testDeserializeArrayOfObject()
22+
{
23+
if (!class_exists(DataUriNormalizer::class)) {
24+
$this->markTestSkipped('This test is only applicable when using the Symfony Serializer Component version 3.1 or superior.');
25+
}
26+
27+
static::bootKernel(array('test_case' => 'Serializer'));
28+
$container = static::$kernel->getContainer();
29+
30+
$result = $container->get('serializer')->deserialize('{"bars": [{"id": 1}, {"id": 2}]}', Foo::class, 'json');
31+
32+
$bar1 = new Bar();
33+
$bar1->id = 1;
34+
$bar2 = new Bar();
35+
$bar2->id = 2;
36+
37+
$expected = new Foo();
38+
$expected->bars = array($bar1, $bar2);
39+
40+
$this->assertEquals($expected, $result);
41+
}
42+
}
43+
44+
class Foo
45+
{
46+
/**
47+
* @var Bar[]
48+
*/
49+
public $bars;
50+
}
51+
52+
class Bar
53+
{
54+
/**
55+
* @var int
56+
*/
57+
public $id;
58+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
13+
14+
return array(
15+
new FrameworkBundle(),
16+
);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
imports:
2+
- { resource: ../config/default.yml }
3+
4+
framework:
5+
serializer: { enabled: true }
6+
property_info: { enabled: true }

0 commit comments

Comments
 (0)