Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb556f4f

Browse files
committed
minor#14328 [Serializer] add note on Custom Normalizer page about cacheable performance (maxhelias)
This PR was merged into the 4.4 branch.Discussion----------[Serializer] add note on Custom Normalizer page about cacheable performanceFix#12061Commits-------6d51c6c [Serializer] move note on Custom Normalizer page about cacheable performance
2 parentsfbdd52f +6d51c6c commitb556f4f

File tree

2 files changed

+29
-26
lines changed

2 files changed

+29
-26
lines changed

‎components/serializer.rst‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,32 +1524,6 @@ Once configured, the serializer uses the mapping to pick the correct class::
15241524
$repository = $serializer->deserialize($serialized, CodeRepository::class, 'json');
15251525
// instanceof GitHubCodeRepository
15261526

1527-
Performance
1528-
-----------
1529-
1530-
To figure which normalizer (or denormalizer) must be used to handle an object,
1531-
the:class:`Symfony\\Component\\Serializer\\Serializer` class will call the
1532-
:method:`Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface::supportsNormalization`
1533-
(or:method:`Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface::supportsDenormalization`)
1534-
of all registered normalizers (or denormalizers) in a loop.
1535-
1536-
The result of these methods can vary depending on the object to serialize, the
1537-
format and the context. That's why the result **is not cached** by default and
1538-
can result in a significant performance bottleneck.
1539-
1540-
However, most normalizers (and denormalizers) always return the same result when
1541-
the object's type and the format are the same, so the result can be cached. To
1542-
do so, make those normalizers (and denormalizers) implement the
1543-
:class:`Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface`
1544-
and return ``true`` when
1545-
:method:`Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface::hasCacheableSupportsMethod`
1546-
is called.
1547-
1548-
..note::
1549-
1550-
All built-in:ref:`normalizers and denormalizers<component-serializer-normalizers>`
1551-
as well the ones included in `API Platform`_ natively implement this interface.
1552-
15531527
Learn more
15541528
----------
15551529

‎serializer/custom_normalizer.rst‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,32 @@ Before using this normalizer in a Symfony application it must be registered as
6161
a service and:doc:`tagged</service_container/tags>` with ``serializer.normalizer``.
6262
If you're using the:ref:`default services.yaml configuration<service-container-services-load-example>`,
6363
this is done automatically!
64+
65+
Performance
66+
-----------
67+
68+
To figure which normalizer (or denormalizer) must be used to handle an object,
69+
the:class:`Symfony\\Component\\Serializer\\Serializer` class will call the
70+
:method:`Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface::supportsNormalization`
71+
(or:method:`Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface::supportsDenormalization`)
72+
of all registered normalizers (or denormalizers) in a loop.
73+
74+
The result of these methods can vary depending on the object to serialize, the
75+
format and the context. That's why the result **is not cached** by default and
76+
can result in a significant performance bottleneck.
77+
78+
However, most normalizers (and denormalizers) always return the same result when
79+
the object's type and the format are the same, so the result can be cached. To
80+
do so, make those normalizers (and denormalizers) implement the
81+
:class:`Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface`
82+
and return ``true`` when
83+
:method:`Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface::hasCacheableSupportsMethod`
84+
is called.
85+
86+
..note::
87+
88+
All built-in:ref:`normalizers and denormalizers<component-serializer-normalizers>`
89+
as well the ones included in `API Platform`_ natively implement this interface.
90+
91+
.. _`API Platform`:https://api-platform.com
92+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp