@@ -789,13 +789,13 @@ When serializing, you can set a callback to format a specific object property::
789789Normalizers
790790-----------
791791
792- Normalizers turn **object ** into **array ** and vice versa. They implement
793- :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ NormalizableInterface `
794- for normalize (object to array) and
795- :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DenormalizableInterface ` for denormalize
796- (array to object).
792+ Normalizers turn **objects ** into **arrays ** and vice versa. They implement
793+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ NormalizerInterface ` for
794+ normalizing (object to array) and
795+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ DenormalizerInterface ` for
796+ denormalizing (array to object).
797797
798- You can add new normalizers to a Serializer instance by using its first constructor argument::
798+ Normalizers are enabled in the serializer passing them as its first argument::
799799
800800 use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
801801 use Symfony\Component\Serializer\Serializer;
@@ -908,6 +908,56 @@ The Serializer component provides several built-in normalizers:
908908
909909 The ``UidNormalizer `` normalization formats were introduced in Symfony 5.3.
910910
911+ Certain normalizers are enabled by default when using the Serializer component
912+ in a Symfony application, additional ones can be enabled by tagging them with
913+ :ref: `serializer.normalizer <reference-dic-tags-serializer-normalizer >`.
914+
915+ Here is an example of how to enable the built-in
916+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ GetSetMethodNormalizer `, a
917+ faster alternative to the
918+ :class: `Symfony\\ Component\\ Serializer\\ Normalizer\\ ObjectNormalizer `:
919+
920+ .. configuration-block ::
921+
922+ .. code-block :: yaml
923+
924+ # config/services.yaml
925+ services :
926+ get_set_method_normalizer :
927+ class : Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
928+ tags : [serializer.normalizer]
929+
930+ .. code-block :: xml
931+
932+ <!-- config/services.xml -->
933+ <?xml version =" 1.0" encoding =" UTF-8" ?>
934+ <container xmlns =" http://symfony.com/schema/dic/services"
935+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
936+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
937+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
938+
939+ <services >
940+ <service id =" get_set_method_normalizer" class =" Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer" >
941+ <tag name =" serializer.normalizer" />
942+ </service >
943+ </services >
944+ </container >
945+
946+ .. code-block :: php
947+
948+ // config/services.php
949+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
950+
951+ use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
952+
953+ return function(ContainerConfigurator $configurator) {
954+ $services = $configurator->services();
955+
956+ $services->set('get_set_method_normalizer', GetSetMethodNormalizer::class)
957+ ->tag('serializer.normalizer')
958+ ;
959+ };
960+
911961 .. _component-serializer-encoders :
912962
913963Encoders
0 commit comments