From 32c90ebc8e5061a4170045cca2d0c61214078b4f Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Wed, 7 Nov 2018 18:51:10 +0100 Subject: [PATCH] [Serializer] Normalize constraint violation parameters --- src/Symfony/Component/Serializer/CHANGELOG.md | 5 +++++ .../Normalizer/ConstraintViolationListNormalizer.php | 1 + .../Normalizer/ConstraintViolationListNormalizerTest.php | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Serializer/CHANGELOG.md b/src/Symfony/Component/Serializer/CHANGELOG.md index 99f32abff1..57e4ed1fd7 100644 --- a/src/Symfony/Component/Serializer/CHANGELOG.md +++ b/src/Symfony/Component/Serializer/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +4.3.0 +----- + + * added the list of constraint violations' parameters in `ConstraintViolationListNormalizer` + 4.2.0 ----- diff --git a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php index aa45a0fc1b..051ceaf3a3 100644 --- a/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php +++ b/src/Symfony/Component/Serializer/Normalizer/ConstraintViolationListNormalizer.php @@ -49,6 +49,7 @@ class ConstraintViolationListNormalizer implements NormalizerInterface, Cacheabl $violationEntry = [ 'propertyPath' => $propertyPath, 'title' => $violation->getMessage(), + 'parameters' => $violation->getParameters(), ]; if (null !== $code = $violation->getCode()) { $violationEntry['type'] = sprintf('urn:uuid:%s', $code); diff --git a/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php b/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php index fa406ff227..86008f361a 100644 --- a/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php +++ b/src/Symfony/Component/Serializer/Tests/Normalizer/ConstraintViolationListNormalizerTest.php @@ -38,7 +38,7 @@ class ConstraintViolationListNormalizerTest extends TestCase public function testNormalize() { $list = new ConstraintViolationList([ - new ConstraintViolation('a', 'b', [], 'c', 'd', 'e', null, 'f'), + new ConstraintViolation('a', 'b', ['value' => 'foo'], 'c', 'd', 'e', null, 'f'), new ConstraintViolation('1', '2', [], '3', '4', '5', null, '6'), ]); @@ -52,11 +52,15 @@ class ConstraintViolationListNormalizerTest extends TestCase 'propertyPath' => 'd', 'title' => 'a', 'type' => 'urn:uuid:f', + 'parameters' => [ + 'value' => 'foo', + ], ], [ 'propertyPath' => '4', 'title' => '1', 'type' => 'urn:uuid:6', + 'parameters' => [], ], ], ];