8000 Add documentation for RouterContextMiddleware · symfony/symfony-docs@5f87669 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5f87669

Browse files
committed
Add documentation for RouterContextMiddleware
1 parent 9b334b0 commit 5f87669

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
@@ -1954,6 +1954,67 @@ may want to use:
19541954
],
19551955
]);
19561956
1957+
Other Middlewares
1958+
~~~~~~~~~~~~~~~~~
1959+
1960+
.. versionadded:: 5.3
1961+
1962+
The ``router_context`` middleware were introduced in Symfony 5.3.
1963+
1964+
When the consumer needs to build an absolute URL, for instance: rendering a
1965+
template with links, it needs the initial's request context in order to
1966+
retrieves the domain and informations needed to build the URL. This can be
1967+
achieved by declaring the ``router_context`` middleware in the bus.
1968+
1969+
.. configuration-block::
1970+
1971+
.. code-block:: yaml
1972+
1973+
# config/packages/messenger.yaml
1974+
framework:
1975+
messenger:
1976+
buses:
1977+
command_bus:
1978+
middleware:
1979+
- router_context
1980+
1981+
.. code-block:: xml
1982+
1983+
<!-- config/packages/messenger.xml -->
1984+
<?xml version="1.0" encoding="UTF-8" ?>
1985+
<container xmlns="http://symfony.com/schema/dic/services"
1986+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1987+
xmlns:framework="http://symfony.com/schema/dic/symfony"
1988+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1989+
https://symfony.com/schema/dic/services/services-1.0.xsd
1990+
http://symfony.com/schema/dic/symfony
1991+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1992+
1993+
<framework:config>
1994+
<framework:messenger>
1995+
<framework:bus name="command_bus">
1996+
<framework:middleware id="router_context"/>
1997+
</framework:bus>
1998+
</framework:messenger>
1999+
</framework:config>
2000+
</container>
2001+
2002+
.. code-block:: php
2003+
2004+
// config/packages/messenger.php
2005+
$container->loadFromExtension('framework', [
2006+
'messenger' => [
2007+
'buses' => [
2008+
'command_bus' => [
2009+
'middleware' => [
2010+
'router_context',
2011+
],
2012+
],
2013+
],
2014+
],
2015+
]);
2016+
2017+
19572018
Messenger Events
19582019
~~~~~~~~~~~~~~~~
19592020

0 commit comments

Comments
 (0)
0