Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit aabb6c5

Browse filesBrowse files
committed
feature #16337 [Messenger] Document the validation middleware (94noni)
This PR was submitted for the 5.4 branch but it was squashed and merged into the 4.4 branch instead. Discussion ---------- [Messenger] Document the validation middleware Close #10474 I took inspiration on the doc https://symfonycasts.com/screencast/messenger/other-middleware#validation-doctrine-transaction-etc-middleware Reference this doc #14969 so I added next to it Commits ------- 0fc886d [Messenger] Document the validation middleware
2 parents dbd274c + 0fc886d commit aabb6c5
Copy full SHA for aabb6c5

File tree

Expand file treeCollapse file tree

1 file changed

+61
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+61
-0
lines changed

‎messenger.rst

Copy file name to clipboardExpand all lines: messenger.rst
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,67 @@ may want to use:
17301730
],
17311731
]);
17321732
1733+
Other Middlewares
1734+
~~~~~~~~~~~~~~~~~
1735+
1736+
.. versionadded:: 4.1
1737+
1738+
The ``validation`` middleware was introduced in Symfony 4.1.
1739+
1740+
Add the ``validation`` middleware if you need to validate the message
1741+
object using the :doc:`Validator component <validator>` before handling it.
1742+
If validation fails, a ``ValidationFailedException`` will be thrown. The
1743+
:class:`Symfony\\Component\\Messenger\\Stamp\\ValidationStamp` can be used
1744+
to configure the validation groups.
1745+
1746+
.. configuration-block::
1747+
1748+
.. code-block:: yaml
1749+
1750+
# config/packages/messenger.yaml
1751+
framework:
1752+
messenger:
1753+
buses:
1754+
command_bus:
1755+
middleware:
1756+
- validation
1757+
1758+
.. code-block:: xml
1759+
1760+
<!-- config/packages/messenger.xml -->
1761+
<?xml version="1.0" encoding="UTF-8" ?>
1762+
<container xmlns="http://symfony.com/schema/dic/services"
1763+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1764+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1765+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1766+
https://symfony.com/schema/dic/services/services-1.0.xsd
1767+
http://symfony.com/schema/dic/symfony
1768+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1769+
1770+
<framework:config>
1771+
<framework:messenger>
1772+
<framework:bus name="command_bus">
1773+
<framework:middleware id="validation"/>
1774+
</framework:bus>
1775+
</framework:messenger>
1776+
</framework:config>
1777+
</container>
1778+
1779+
.. code-block:: php
1780+
1781+
// config/packages/messenger.php
1782+
$container->loadFromExtension('framework', [
1783+
'messenger' => [
1784+
'buses' => [
1785+
'command_bus' => [
1786+
'middleware' => [
1787+
'validation',
1788+
],
1789+
],
1790+
],
1791+
],
1792+
]);
1793+
17331794
Messenger Events
17341795
~~~~~~~~~~~~~~~~
17351796

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.