Skip to content

Commit e21c3f7

Browse files
committed
[Serializer] Add UidNormalizer normalization formats
1 parent f46e4e2 commit e21c3f7

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

components/serializer.rst

+16-3
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,26 @@ There are several types of normalizers available:
812812

813813
:class:`Symfony\\Component\\Serializer\\Normalizer\\UidNormalizer`
814814
This normalizer converts objects that implement
815-
:class:`Symfony\\Component\\Uid\\AbstractUid` into strings. Also it can
816-
denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid`
817-
or :class:`Symfony\\Component\\Uid\\Ulid`.
815+
:class:`Symfony\\Component\\Uid\\AbstractUid` into strings.
816+
The default normalization format for objects that implement :class:`Symfony\\Component\\Uid\\Uuid`
817+
is the `RFC 4122`_ format (example: ``d9e7a184-5d5b-11ea-a62a-3499710062d0``).
818+
The default normalization format for objects that implement :class:`Symfony\\Component\\Uid\\Ulid`
819+
is the Base 32 format (example: ``01E439TP9XJZ9RPFH3T1PYBCR8``).
820+
You can change the string format by setting the serializer context option
821+
``UidNormalizer::NORMALIZATION_FORMAT_KEY`` to ``UidNormalizer::NORMALIZATION_FORMAT_BASE_58``,
822+
``UidNormalizer::NORMALIZATION_FORMAT_BASE_32`` or ``UidNormalizer::NORMALIZATION_FORMAT_RFC_4122``.
823+
824+
Also it can denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid`
825+
or :class:`Symfony\\Component\\Uid\\Ulid`. The format does not matter.
818826

819827
.. versionadded:: 5.2
820828

821829
The ``UidNormalizer`` was introduced in Symfony 5.2.
822830

831+
.. versionadded:: 5.3
832+
833+
The ``UidNormalizer`` normalization formats were introduced in Symfony 5.3.
834+
823835
.. _component-serializer-encoders:
824836

825837
Encoders
@@ -1558,3 +1570,4 @@ Learn more
15581570
.. _`Value Objects`: https://en.wikipedia.org/wiki/Value_object
15591571
.. _`API Platform`: https://api-platform.com
15601572
.. _`list of PHP timezones`: https://www.php.net/manual/en/timezones.php
1573+
.. _`RFC 4122`: https://tools.ietf.org/html/rfc4122

0 commit comments

Comments
 (0)