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

Commitcbf2d22

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [Serializer] move note on Custom Normalizer page about cacheable performance
2 parentscd4fba1 +b556f4f commitcbf2d22

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
@@ -1476,32 +1476,6 @@ Once configured, the serializer uses the mapping to pick the correct class::
14761476
$repository = $serializer->deserialize($serialized, CodeRepository::class, 'json');
14771477
// instanceof GitHubCodeRepository
14781478

1479-
Performance
1480-
-----------
1481-
1482-
To figure which normalizer (or denormalizer) must be used to handle an object,
1483-
the:class:`Symfony\\Component\\Serializer\\Serializer` class will call the
1484-
:method:`Symfony\\Component\\Serializer\\Normalizer\\NormalizerInterface::supportsNormalization`
1485-
(or:method:`Symfony\\Component\\Serializer\\Normalizer\\DenormalizerInterface::supportsDenormalization`)
1486-
of all registered normalizers (or denormalizers) in a loop.
1487-
1488-
The result of these methods can vary depending on the object to serialize, the
1489-
format and the context. That's why the result **is not cached** by default and
1490-
can result in a significant performance bottleneck.
1491-
1492-
However, most normalizers (and denormalizers) always return the same result when
1493-
the object's type and the format are the same, so the result can be cached. To
1494-
do so, make those normalizers (and denormalizers) implement the
1495-
:class:`Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface`
1496-
and return ``true`` when
1497-
:method:`Symfony\\Component\\Serializer\\Normalizer\\CacheableSupportsMethodInterface::hasCacheableSupportsMethod`
1498-
is called.
1499-
1500-
..note::
1501-
1502-
All built-in:ref:`normalizers and denormalizers<component-serializer-normalizers>`
1503-
as well the ones included in `API Platform`_ natively implement this interface.
1504-
15051479
Learn more
15061480
----------
15071481

‎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