File tree 1 file changed +8
-1
lines changed
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
988
988
989
989
When dealing with objects that are fairly similar or share properties, you may
990
990
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" *.
992
992
993
993
The discriminator is the field (in the serialized string) used to differentiate
994
994
between the possible objects. In practice, when using the Serializer component,
@@ -999,6 +999,13 @@ Consider an application that defines an abstract ``CodeRepository`` class
999
999
extended by ``GitHubCodeRepository `` and ``BitBucketCodeRepository `` classes.
1000
1000
This example shows how to serialize and deserialize those objects::
1001
1001
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
+
1002
1009
$discriminator = new ClassDiscriminatorResolver();
1003
1010
$discriminator->addClassMapping(CodeRepository::class, new ClassDiscriminatorMapping('type', [
1004
1011
'github' => GitHubCodeRepository::class,
You can’t perform that action at this time.
0 commit comments