8000 minor #14969 [Messenger] Add documentation for RouterContextMiddlewar… · symfony/symfony-docs@7aad004 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7aad004

Browse files
committed
minor #14969 [Messenger] Add documentation for RouterContextMiddleware (jderusse)
This PR was merged into the 5.3-dev branch. Discussion ---------- [Messenger] Add documentation for RouterContextMiddleware fixes #14952 Commits ------- 6f212d9 Add documentation for RouterContextMiddleware
2 parents 4e31dd9 + 6f212d9 commit 7aad004

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

messenger.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1976,6 +1976,67 @@ may want to use:
19761976
],
19771977
]);
19781978
1979+
Other Middlewares
1980+
~~~~~~~~~~~~~~~~~
1981+
1982+
.. versionadded:: 5.3
1983+
1984+
The ``router_context`` middleware were introduced in Symfony 5.3.
1985+
1986+
When the consumer needs to build an absolute URL, for instance: rendering a
1987+
template with links, it needs the initial's request context in order to
1988+
retrieves the domain and information needed to build the URL. This can be
1989+
achieved by declaring the ``router_context`` middleware in the bus.
1990+
1991+
.. configuration-block::
1992+
1993+
.. code-block:: yaml
1994+
1995+
# config/packages/messenger.yaml
1996+
framework:
1997+
messenger:
1998+
buses:
1999+
command_bus:
2000+
middleware:
2001+
- router_context
2002+
2003+
.. code-block:: xml
2004+
2005+
<!-- config/packages/messenger.xml -->
2006+
<?xml version="1.0" encoding="UTF-8" ?>
2007+
<container xmlns="http://symfony.com/schema/dic/services"
2008+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2009+
xmlns:framework="http://symfony.com/schema/dic/symfony"
2010+
xsi:schemaLocation="http://symfony.com/schema/dic/services
2011+
https://symfony.com/schema/dic/services/services-1.0.xsd
2012+
http://symfony.com/schema/dic/symfony
2013+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
2014+
2015+
<framework:config>
2016+
<framework:messenger>
2017+
<framework:bus name="command_bus">
2018+
<framework:middleware id="router_context"/>
2019+
</framework:bus>
2020+
</framework:messenger>
2021+
</framework:config>
2022+
</container>
2023+
2024+
.. code-block:: php
2025+
2026+
// config/packages/messenger.php
2027+
$container->loadFromExtension('framework', [
2028+
'messenger' => [
2029+
'buses' => [
2030+
'command_bus' => [
2031+
'middleware' => [
2032+
'router_context',
2033+
],
2034+
],
2035+
],
2036+
],
2037+
]);
2038+
2039+
19792040
Messenger Events
19802041
~~~~~~~~~~~~~~~~
19812042

0 commit comments

Comments
 (0)
0