Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit b975106

Browse files
committed
Merge pull request #639 from symfony-cmf/container_provider
Documentation for RutingAuto container provider
2 parents 4904733 + d65c68c commit b975106

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

bundles/routing_auto/token_providers.rst

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ generated or from the environment (e.g. you could use the current locale in
1010
the route).
1111

1212

13-
content_method
14-
--------------
13+
``content_method``
14+
------------------
1515

1616
The ``content_method`` provider allows the content object (e.g. a forum
1717
``Topic``) to specify a path using one of its methods. This is quite a powerful
@@ -117,6 +117,42 @@ feature.
117117
</mapping>
118118
</auto-mapping>
119119
120+
``container``
121+
-------------
122+
123+
.. versionadded:: 1.1
124+
The container provider was introduced in RoutingAutoBundle 1.1
125+
126+
The ``container`` provider allows you to use parameters which have
127+
been defined in the Symfony DI container.
128+
129+
.. configuration-block::
130+
131+
.. code-block:: yaml
132+
133+
# src/Acme/ForumBundle/Resources/config/cmf_routing_auto.yml
134+
Acme\ForumBundle\Document\Article:
135+
uri_schema: {base_url}/good-day
136+
token_providers:
137+
base_url: [container, { parameter: my_parameter.base_path }
138+
139+
.. code-block: xml
140+
141+
<!-- src/Acme/ForumBundle/Resources/config/cmf_routing_auto.xml -->
142+
<?xml version="1.0" ?>
143+
<auto-mapping xmlns="http://cmf.symfony.com/schema/routing_auto">
144+
<mapping class="Acme\ForumBundle\Document\Article" uri-schema="/{base_url}/good-day">
145+
<token-provider token="base_url" name="container" >
146+
<option name="parameter">my_parameter.base_path</option>
147+
</token>
148+
</mapping>
149+
</auto-mapping>
150+
151+
.. note::
152+
153+
Parameters from the container will not be slugified. It is your
154+
responsibility to ensure that they contain safe characters.
155+
120156
Options
121157
~~~~~~~
122158

0 commit comments

Comments
 (0)