8000 Fix merge · symfony/symfony-docs@0aea09a · GitHub
[go: up one dir, main page]

Skip to content

Commit 0aea09a

Browse files
committed
Fix merge
1 parent 96e13be commit 0aea09a

File tree

1 file changed

+9
-62
lines changed

1 file changed

+9
-62
lines changed

messenger.rst

Lines changed: 9 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,6 +2152,12 @@ the consumer (e.g. render a template with links). This middleware stores the
21522152
original request context (i.e. the host, the HTTP port, etc.) which is needed
21532153
when building absolute URLs.
21542154

2155+
Add the ``validation`` middleware if you need to validate the message
2156+
object using the :doc:`Validator component <validator>` before handling it.
2157+
If validation fails, a ``ValidationFailedException`` will be thrown. The
2158+
:class:`Symfony\\Component\\Messenger\\Stamp\\ValidationStamp` can be used
2159+
to configure the validation groups.
2160+
21552161
.. configuration-block::
21562162

21572163
.. code-block:: yaml
@@ -2163,6 +2169,7 @@ when building absolute URLs.
21632169
command_bus:
21642170
middleware:
21652171
- router_context
2172+
- validation
21662173
21672174
.. code-block:: xml
21682175
@@ -2180,6 +2187,7 @@ when building absolute URLs.
21802187
<framework:messenger>
21812188
<framework:bus name="command_bus">
21822189
<framework:middleware id="router_context"/>
2190+
<framework:middleware id="validation"/>
21832191
</framework:bus>
21842192
</framework:messenger>
21852193
</framework:config>
@@ -2195,70 +2203,9 @@ when building absolute URLs.
21952203
21962204
$bus = $messenger->bus('command_bus');
21972205
$bus->middleware()->id('router_context');
2206+
$bus->middleware()->id('validation');
21982207
};
21992208
2200-
2201-
Other Middlewares
2202-
~~~~~~~~~~~~~~~~~
2203-
2204-
.. versionadded:: 4.1
2205-
2206-
The ``validation`` middleware was introduced in Symfony 4.1.
2207-
2208-
Add the ``validation`` middleware if you need to validate the message
2209-
object using the :doc:`Validator component <validator>` before handling it.
2210-
If validation fails, a ``ValidationFailedException`` will be thrown. The
2211-
:class:`Symfony\\Component\\Messenger\\Stamp\\ValidationStamp` can be used
2212-
to configure the validation groups.
2213-
2214-
.. configuration-block::
2215-
2216-
.. code-block:: yaml
2217-
2218-
# config/packages/messenger.yaml
2219-
framework:
2220-
messenger:
2221-
buses:
2222-
command_bus:
2223-
middleware:
2224-
- validation
2225-
2226-
.. code-block:: xml
2227-
2228-
<!-- config/packages/messenger.xml -->
2229-
<?xml version="1.0" encoding="UTF-8" ?>
2230-
<container xmlns="http://symfony.com/schema/dic/services"
2231-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2232-
xmlns:framework="http://symfony.com/schema/dic/symfony"
2233-
xsi:schemaLocation="http://symfony.com/schema/dic/services
2234-
https://symfony.com/schema/dic/services/services-1.0.xsd
2235-
http://symfony.com/schema/dic/symfony
2236-
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
2237-
2238-
<framework:config>
2239-
<framework:messenger>
2240-
<framework:bus name="command_bus">
2241-
<framework:middleware id="validation"/>
2242-
</framework:bus>
2243-
</framework:messenger>
2244-
</framework:config>
2245-
</container>
2246-
2247-
.. code-block:: php
2248-
2249-
// config/packages/messenger.php
2250-
$container->loadFromExtension('framework', [
2251-
'messenger' => [
2252-
'buses' => [
2253-
'command_bus' => [
2254-
'middleware' => [
2255-
'validation',
2256-
],
2257-
],
2258-
],
2259-
],
2260-
]);
2261-
22622209
Messenger Events
22632210
~~~~~~~~~~~~~~~~
22642211

0 commit comments

Comments
 (0)
0