Skip to content

Commit 886d859

Browse files
committed
Update based on feedback
1 parent 566ebe1 commit 886d859

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ CHANGELOG
2828
* Made `BrowserKitAssertionsTrait` report the original error message in case of a failure
2929
* Added ability for `config:dump-reference` and `debug:config` to dump and debug kernel container extension configuration.
3030
* Deprecated `session.attribute_bag` service and `session.flash_bag` service.
31-
* Added `UidNormalizer` to the framework serializer.
3231

3332
5.0.0
3433
-----

src/Symfony/Bundle/FrameworkBundle/Resources/config/serializer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
4545
use Symfony\Component\Serializer\Normalizer\ProblemNormalizer;
4646
use Symfony\Component\Serializer\Normalizer\PropertyNormalizer;
47+
use Symfony\Component\Serializer\Normalizer\UidNormalizer;
4748
use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
4849
use Symfony\Component\Serializer\Serializer;
4950
use Symfony\Component\Serializer\SerializerInterface;
@@ -106,6 +107,9 @@
106107
->args([service('serializer.property_accessor')])
107108
->tag('serializer.normalizer', ['priority' => 1000])
108109

110+
->set('serializer.normalizer.uid', UidNormalizer::class)
111+
->tag('serializer.normalizer', ['priority' => -915])
112+
109113
->set('serializer.normalizer.object', ObjectNormalizer::class)
110114
->args([
111115
service('serializer.mapping.class_metadata_factory'),

src/Symfony/Component/Serializer/CHANGELOG.md

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

77
* added `CompiledClassMetadataFactory` and `ClassMetadataFactoryCompiler` for faster metadata loading.
8+
* added `UidNormalizer`
89

910
5.1.0
1011
-----
@@ -13,7 +14,6 @@ CHANGELOG
1314
* added support for `\stdClass` to `ObjectNormalizer`
1415
* added the ability to ignore properties using metadata (e.g. `@Symfony\Component\Serializer\Annotation\Ignore`)
1516
* added an option to serialize constraint violations payloads (e.g. severity)
16-
* added `UidNormalizer`
1717

1818
5.0.0
1919
-----

src/Symfony/Component/Serializer/Normalizer/UidNormalizer.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@ final class UidNormalizer implements NormalizerInterface, DenormalizerInterface,
2222
{
2323
/**
2424
* {@inheritdoc}
25-
*
26-
* @throws InvalidArgumentException
2725
*/
2826
public function normalize($object, string $format = null, array $context = [])
2927
{
30-
if (!$object instanceof AbstractUid) {
31-
throw new InvalidArgumentException('The object must be an instance of "\Symfony\Component\Uid\AbstractUid".');
32-
}
33-
3428
return (string) $object;
3529
}
3630

@@ -44,19 +38,13 @@ public function supportsNormalization($data, string $format = null)
4438

4539
/**
4640
* {@inheritdoc}
47-
*
48-
* @throws NotNormalizableValueException
4941
*/
5042
public function denormalize($data, string $type, string $format = null, array $context = [])
5143
{
52-
if (!class_exists(AbstractUid::class)) {
53-
throw new LogicException('You cannot use the "Symfony\Component\Serializer\Normalizer\UidNormalizer" as the Symfony Uid Component is not installed. Try running "composer require symfony/uid".');
54-
}
55-
5644
try {
5745
$uid = Ulid::class === $type ? Ulid::fromString($data) : Uuid::fromString($data);
5846
} catch (\InvalidArgumentException $exception) {
59-
throw new NotNormalizableValueException('The data is not a valid '.$type.' string representation.');
47+
throw new NotNormalizableValueException(sprintf('The data is not a valid %s string representation.', $type));
6048
}
6149

6250
return $uid;

0 commit comments

Comments
 (0)