Skip to content

Commit 62c1d4c

Browse files
committed
Merge branch '4.1'
* 4.1: Fixed a file location [Serializer] update doc for 3.4 about normalizer Update dispatch example
2 parents 0abd108 + 678e95b commit 62c1d4c

File tree

2 files changed

+8
-43
lines changed

2 files changed

+8
-43
lines changed

components/messenger.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Example::
7070
])),
7171
]);
7272

73-
$result = $bus->dispatch(new MyMessage(/* ... */));
73+
$bus->dispatch(new MyMessage(/* ... */));
7474

7575
.. note::
7676

serializer/custom_normalizer.rst

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ process. For that you'll have to create your own normalizer. But it's usually
1717
preferable to let Symfony normalize the object, then hook into the normalization
1818
to customize the normalized data. To do that, leverage the ``ObjectNormalizer``::
1919

20-
namespace AppBundle\Serializer;
20+
namespace App\Serializer;
2121

22-
use AppBundle\Entity\Topic;
22+
use App\Entity\Topic;
2323
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2424
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
2525
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
@@ -53,45 +53,10 @@ to customize the normalized data. To do that, leverage the ``ObjectNormalizer``:
5353
}
5454
}
5555

56-
Registering it in Your Application
56+
Registering it in your Application
5757
----------------------------------
5858

59-
In order to enable the normalizer in an application based on the entire Symfony
60-
framework, you must register it as a service and :doc:`tag it </service_container/tags>`
61-
with ``serializer.normalizer``.
62-
63-
.. configuration-block::
64-
65-
.. code-block:: yaml
66-
67-
# app/config/services.yml
68-
services:
69-
app.yaml_encoder:
70-
class: AppBundle\Serializer\TopicNormalizer
71-
tags:
72-
- { name: serializer.normalizer }
73-
74-
.. code-block:: xml
75-
76-
<!-- app/config/services.xml -->
77-
<?xml version="1.0" encoding="UTF-8" ?>
78-
<container xmlns="http://symfony.com/schema/dic/services"
79-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
80-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
81-
82-
<services>
83-
<service id="app.yaml_encoder" class="AppBundle\Serializer\TopicNormalizer">
84-
<tag name="serializer.normalizer" />
85-
</service>
86-
</services>
87-
</container>
88-
89-
.. code-block:: php
90-
91-
// app/config/services.php
92-
use AppBundle\Serializer\TopicNormalizer;
93-
94-
$container
95-
->register('app.yaml_encoder', TopicNormalizer::class)
96-
->addTag('serializer.normalizer')
97-
;
59+
Before using this normalizer in a Symfony application it must be registered as
60+
a service and :doc:`tagged </service_container/tags>` with ``serializer.normalizer``.
61+
If you're using the :ref:`default services.yaml configuration <service-container-services-load-example>`,
62+
this is done automatically!

0 commit comments

Comments
 (0)