File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -988,7 +988,7 @@ Serializing Interfaces and Abstract Classes
988988
989989When dealing with objects that are fairly similar or share properties, you may
990990use 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
993993The discriminator is the field (in the serialized string) used to differentiate
994994between the possible objects. In practice, when using the Serializer component,
@@ -999,6 +999,13 @@ Consider an application that defines an abstract ``CodeRepository`` class
999999extended by ``GitHubCodeRepository `` and ``BitBucketCodeRepository `` classes.
10001000This 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,
You can’t perform that action at this time.
0 commit comments