Skip to content

Commit b655166

Browse files
committed
minor #9077 Minor improvements in the new abstract serializer doc (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Minor improvements in the new abstract serializer doc Commits ------- 88f7364 Minor improvements in the new abstract serializer doc
2 parents e9183f6 + 88f7364 commit b655166

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

components/serializer.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ Serializing Interfaces and Abstract Classes
988988

989989
When dealing with objects that are fairly similar or share properties, you may
990990
use interfaces or abstract classes. The Serializer component allows you to
991-
serialize and deserialize these objects using a *"discrimator class mapping"*.
991+
serialize and deserialize these objects using a *"discriminator class mapping"*.
992992

993993
The discriminator is the field (in the serialized string) used to differentiate
994994
between the possible objects. In practice, when using the Serializer component,
@@ -999,6 +999,13 @@ Consider an application that defines an abstract ``CodeRepository`` class
999999
extended by ``GitHubCodeRepository`` and ``BitBucketCodeRepository`` classes.
10001000
This example shows how to serialize and deserialize those objects::
10011001

1002+
// ...
1003+
use Symfony\Component\Serializer\Encoder\JsonEncoder;
1004+
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorMapping;
1005+
use Symfony\Component\Serializer\Mapping\ClassDiscriminatorResolver;
1006+
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
1007+
use Symfony\Component\Serializer\Serializer;
1008+
10021009
$discriminator = new ClassDiscriminatorResolver();
10031010
$discriminator->addClassMapping(CodeRepository::class, new ClassDiscriminatorMapping('type', [
10041011
'github' => GitHubCodeRepository::class,

0 commit comments

Comments
 (0)