@@ -545,8 +545,8 @@ When serializing, you can set a callback to format a specific object property::
545
545
$encoder = new JsonEncoder();
546
546
$normalizer = new GetSetMethodNormalizer();
547
547
548
+ // all callback parameters are optional (you can omit the ones you don't use)
548
549
$callback = function ($innerObject, $outerObject, string $attributeName, string $format = null, array $context = array()) {
549
- // Every parameters can be omitted if not used
550
550
return $dateTime instanceof \DateTime ? $dateTime->format(\DateTime::ISO8601) : '';
551
551
};
552
552
@@ -566,7 +566,6 @@ When serializing, you can set a callback to format a specific object property::
566
566
The ``$outerObject ``, ``$attributeName ``, ``$format `` and ``$context ``
567
567
parameters of the callback were introduced in Symfony 4.2.
568
568
569
-
570
569
.. _component-serializer-normalizers :
571
570
572
571
Normalizers
@@ -832,8 +831,8 @@ having unique identifiers::
832
831
$encoder = new JsonEncoder();
833
832
$normalizer = new ObjectNormalizer();
834
833
834
+ // all callback parameters are optional (you can omit the ones you don't use)
835
835
$normalizer->setCircularReferenceHandler(function ($object, string $format = null, array $context = array()) {
836
- // Every parameters can be omitted if not used
837
836
return $object->getName();
838
837
});
839
838
@@ -842,7 +841,8 @@ having unique identifiers::
842
841
// {"name":"Les-Tilleuls.coop","members":[{"name":"K\u00e9vin", organization: "Les-Tilleuls.coop"}]}
843
842
844
843
.. 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.
846
846
847
847
Handling Serialization Depth
848
848
----------------------------
@@ -972,8 +972,8 @@ having unique identifiers::
972
972
973
973
$classMetadataFactory = new ClassMetadataFactory(new AnnotationLoader(new AnnotationReader()));
974
974
$normalizer = new ObjectNormalizer($classMetadataFactory);
975
+ // all callback parameters are optional (you can omit the ones you don't use)
975
976
$normalizer->setMaxDepthHandler(function ($innerObject, $outerObject, string $attributeName, string $format = null, array $context = array()) {
976
- // Every parameters can be omitted if not used
977
977
return '/foos/'.$innerObject->id;
978
978
});
979
979
0 commit comments