Skip to content

Commit 38448a0

Browse files
committed
Merge branch '5.4' into 6.0
* 5.4: Add the redirection for the removed page fix Password Hasher php-standalone example Remove redundant normalizers document Fix invalid statement about normalizers
2 parents a61d7f3 + e6e7467 commit 38448a0

File tree

5 files changed

+58
-80
lines changed

5 files changed

+58
-80
lines changed

_build/redirection_map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@
516516
/testing/functional_tests_assertions /testing#testing-application-assertions
517517
/components https://symfony.com/components
518518
/components/index https://symfony.com/components
519+
/serializer/normalizers /components/serializer#normalizers
519520
/logging/monolog_regex_based_excludes /logging/monolog_exclude_http_codes
520521
/security/named_encoders /security/named_hashers
521522
/components/inflector /components/string#inflector

components/serializer.rst

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,13 @@ When serializing, you can set a callback to format a specific object property::
789789
Normalizers
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;
@@ -900,6 +900,56 @@ The Serializer component provides several built-in normalizers:
900900
Also it can denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid`
901901
or :class:`Symfony\\Component\\Uid\\Ulid`. The format does not matter.
902902

903+
Certain normalizers are enabled by default when using the Serializer component
904+
in a Symfony application, additional ones can be enabled by tagging them with
905+
:ref:`serializer.normalizer <reference-dic-tags-serializer-normalizer>`.
906+
907+
Here is an example of how to enable the built-in
908+
:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`, a
909+
faster alternative to the
910+
:class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer`:
911+
912+
.. configuration-block::
913+
914+
.. code-block:: yaml
915+
916+
# config/services.yaml
917+
services:
918+
get_set_method_normalizer:
919+
class: Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
920+
tags: [serializer.normalizer]
921+
922+
.. code-block:: xml
923+
924+
<!-- config/services.xml -->
925+
<?xml version="1.0" encoding="UTF-8" ?>
926+
<container xmlns="http://symfony.com/schema/dic/services"
927+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
928+
xsi:schemaLocation="http://symfony.com/schema/dic/services
929+
https://symfony.com/schema/dic/services/services-1.0.xsd">
930+
931+
<services>
932+
<service id="get_set_method_normalizer" class="Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer">
933+
<tag name="serializer.normalizer"/>
934+
</service>
935+
</services>
936+
</container>
937+
938+
.. code-block:: php
939+
940+
// config/services.php
941+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
942+
943+
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
944+
945+
return function(ContainerConfigurator $configurator) {
946+
$services = $configurator->services();
947+
948+
$services->set('get_set_method_normalizer', GetSetMethodNormalizer::class)
949+
->tag('serializer.normalizer')
950+
;
951+
};
952+
903953
.. _component-serializer-encoders:
904954

905955
Encoders

security/passwords.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ optionally some *algorithm options*:
9595
User::class => ['algorithm' => 'auto'],
9696
9797
// auto hasher with custom options for all PasswordAuthenticatedUserInterface instances
98-
User::class => [
98+
PasswordAuthenticatedUserInterface::class => [
9999
'algorithm' => 'auto',
100100
'cost' => 15,
101101
],

serializer.rst

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -89,53 +89,6 @@ possible to set the priority of the tag in order to decide the matching order.
8989
``DateTime`` or ``DateTimeImmutable`` classes to avoid excessive memory
9090
usage and exposing internal details.
9191

92-
Here is an example on how to load the built-in
93-
:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`, a
94-
faster alternative to the `ObjectNormalizer` when data objects always use
95-
getters (``getXxx()``), issers (``isXxx()``) or hassers (``hasXxx()``) to read
96-
properties and setters (``setXxx()``) to change properties:
97-
98-
.. configuration-block::
99-
100-
.. code-block:: yaml
101-
102-
# config/services.yaml
103-
services:
104-
get_set_method_normalizer:
105-
class: Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer
106-
tags: [serializer.normalizer]
107-
108-
.. code-block:: xml
109-
110-
<!-- config/services.xml -->
111-
<?xml version="1.0" encoding="UTF-8" ?>
112-
<container xmlns="http://symfony.com/schema/dic/services"
113-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
114-
xsi:schemaLocation="http://symfony.com/schema/dic/services
115-
https://symfony.com/schema/dic/services/services-1.0.xsd">
116-
117-
<services>
118-
<service id="get_set_method_normalizer" class="Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer">
119-
<tag name="serializer.normalizer"/>
120-
</service>
121-
</services>
122-
</container>
123-
124-
.. code-block:: php
125-
126-
// config/services.php
127-
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
128-
129-
use Symfony\Component\Serializer\Normalizer\GetSetMethodNormalizer;
130-
131-
return function(ContainerConfigurator $configurator) {
132-
$services = $configurator->services();
133-
134-
$services->set('get_set_method_normalizer', GetSetMethodNormalizer::class)
135-
->tag('serializer.normalizer')
136-
;
137-
};
138-
13992
Serializer Context
14093
------------------
14194

@@ -300,7 +253,6 @@ take a look at how this bundle works.
300253
.. toctree::
301254
:maxdepth: 1
302255

303-
serializer/normalizers
304256
serializer/custom_encoders
305257
serializer/custom_normalizer
306258

serializer/normalizers.rst

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)