8000 Merge branch '4.4' into 5.3 · symfony/symfony-docs@96e13be · GitHub
[go: up one dir, main page]

Skip to content

Commit 96e13be

Browse files
committed
Merge branch '4.4' into 5.3
* 4.4: [Messenger] Document the validation middleware Adding redirect to current route
2 parents c24a03e + aabb6c5 commit 96e13be

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

controller.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ If you want to redirect the user to another page, use the ``redirectToRoute()``
132132
and ``redirect()`` methods::
133133

134134
use Symfony\Component\HttpFoundation\RedirectResponse;
135-
use Symfony\Component\HttpFoundation\Response
135+
use Symfony\Component\HttpFoundation\Response;
136136

137137
// ...
138138
public function index(): RedirectResponse
@@ -153,6 +153,9 @@ and ``redirect()`` methods::
153153

154154
// redirects to a route and maintains the original query string parameters
155155
return $this->redirectToRoute('blog_show', $request->query->all());
156+
157+
// redirects to the current route (e.g. for Post/Redirect/Get pattern):
158+
return $this->redirectToRoute($request->attributes->get('_route'));
156159

157160
// redirects externally
158161
return $this->redirect('http://symfony.com/doc');

messenger.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,6 +2198,67 @@ when building absolute URLs.
21982198
};
21992199
22002200
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+
22012262
Messenger Events
22022263
~~~~~~~~~~~~~~~~
22032264

0 commit comments

Comments
 (0)
0