Skip to content

Commit 468da08

Browse files
committed
minor #14799 [Serializer] Add UidNormalizer normalization formats (fancyweb)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Serializer] Add UidNormalizer normalization formats Fix #14794 Commits ------- ebdf28d [Serializer] Add UidNormalizer normalization formats
2 parents 0006353 + ebdf28d commit 468da08

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

components/serializer.rst

+14-9
Original file line numberDiff line numberDiff line change
@@ -829,21 +829,25 @@ The Serializer component provides several built-in normalizers:
829829

830830
:class:`Symfony\\Component\\Serializer\\Normalizer\\UidNormalizer`
831831
This normalizer converts objects that implement
832-
:class:`Symfony\\Component\\Uid\\AbstractUid` into strings. Also it can
833-
denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid`
834-
or :class:`Symfony\\Component\\Uid\\Ulid`.
832+
:class:`Symfony\\Component\\Uid\\AbstractUid` into strings.
833+
The default normalization format for objects that implement :class:`Symfony\\Component\\Uid\\Uuid`
834+
is the `RFC 4122`_ format (example: ``d9e7a184-5d5b-11ea-a62a-3499710062d0``).
835+
The default normalization format for objects that implement :class:`Symfony\\Component\\Uid\\Ulid`
836+
is the Base 32 format (example: ``01E439TP9XJZ9RPFH3T1PYBCR8``).
837+
You can change the string format by setting the serializer context option
838+
``UidNormalizer::NORMALIZATION_FORMAT_KEY`` to ``UidNormalizer::NORMALIZATION_FORMAT_BASE_58``,
839+
``UidNormalizer::NORMALIZATION_FORMAT_BASE_32`` or ``UidNormalizer::NORMALIZATION_FORMAT_RFC_4122``.
840+
841+
Also it can denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid`
842+
or :class:`Symfony\\Component\\Uid\\Ulid`. The format does not matter.
835843

836844
.. versionadded:: 5.2
837845

838846
The ``UidNormalizer`` was introduced in Symfony 5.2.
839847

840-
.. note::
841-
842-
You can also create your own Normalizer to use another structure. Read more at
843-
:doc:`/serializer/custom_normalizer`.
848+
.. versionadded:: 5.3
844849

845-
All these normalizers are enabled by default when using the Serializer component
846-
in a Symfony application.
850+
The ``UidNormalizer`` normalization formats were introduced in Symfony 5.3.
847851

848852
.. _component-serializer-encoders:
849853

@@ -1616,3 +1620,4 @@ Learn more
16161620
.. _`Value Objects`: https://en.wikipedia.org/wiki/Value_object
16171621
.. _`API Platform`: https://api-platform.com
16181622
.. _`list of PHP timezones`: https://www.php.net/manual/en/timezones.php
1623+
.. _`RFC 4122`: https://tools.ietf.org/html/rfc4122

0 commit comments

Comments
 (0)