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

Commit672b374

Browse files
Minor reword
1 parent7c3e620 commit672b374

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

‎components/serializer.rst‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ When serializing, you can set a callback to format a specific object property::
545545
$encoder = new JsonEncoder();
546546
$normalizer = new GetSetMethodNormalizer();
547547

548+
// all callback parameters are optional (you can omit the ones you don't use)
548549
$callback = function ($innerObject, $outerObject, string $attributeName, string $format = null, array $context = array()) {
549-
// Every parameters can be omitted if not used
550550
return $dateTime instanceof \DateTime ? $dateTime->format(\DateTime::ISO8601) : '';
551551
};
552552

@@ -566,7 +566,6 @@ When serializing, you can set a callback to format a specific object property::
566566
The ``$outerObject``, ``$attributeName``, ``$format`` and ``$context``
567567
parameters of the callback were introduced in Symfony 4.2.
568568

569-
570569
.. _component-serializer-normalizers:
571570

572571
Normalizers
@@ -832,8 +831,8 @@ having unique identifiers::
832831
$encoder = new JsonEncoder();
833832
$normalizer = new ObjectNormalizer();
834833

834+
// all callback parameters are optional (you can omit the ones you don't use)
835835
$normalizer->setCircularReferenceHandler(function ($object, string $format = null, array $context = array()) {
836-
// Every parameters can be omitted if not used
837836
return $object->getName();
838837
});
839838

@@ -842,7 +841,8 @@ having unique identifiers::
842841
// {"name":"Les-Tilleuls.coop","members":[{"name":"K\u00e9vin", organization: "Les-Tilleuls.coop"}]}
843842

844843
..versionadded::4.2
845-
The ``$format`` and ``$context`` parameters of ``setCircularReferenceHandler()`` were introduced in Symfony 4.2.
844+
The ``$format`` and ``$context`` parameters of ``setCircularReferenceHandler()``
845+
were introduced in Symfony 4.2.
846846

847847
Handling Serialization Depth
848848
----------------------------
@@ -972,8 +972,8 @@ having unique identifiers::
972972

973973
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
974974
$normalizer = new ObjectNormalizer($classMetadataFactory);
975+
// all callback parameters are optional (you can omit the ones you don't use)
975976
$normalizer->setMaxDepthHandler(function ($innerObject, $outerObject, string $attributeName, string $format = null, array $context = array()) {
976-
// Every parameters can be omitted if not used
977977
return '/foos/'.$innerObject->id;
978978
});
979979

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp