10000 feature #3368 The host parameter has to be in defaults, not requireme… · symfony/symfony-docs@b1e8f56 · GitHub
[go: up one dir, main page]

Skip to content

Commit b1e8f56

Browse files
committed
feature #3368 The host parameter has to be in defaults, not requirements (MarieMinasyan)
This PR was submitted for the 2.4 branch but it was merged into the 2.3 branch instead (closes #3368). Discussion ---------- The host parameter has to be in defaults, not requirements Q | A ------------- | --- Doc fix? | yes New docs? | no Applies to | 2.2+ Also has to be applied to 2.2 & 2.3 branches Commits ------- 8a1afae Moved tip block to remove confusion 9c30509 The host parameter has to be in defaults, not requirements
2 parents 5a3ba1b + d552e69 commit b1e8f56

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

components/routing/hostname_pattern.rst

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,25 +176,27 @@ instance, if you want to match both ``m.example.com`` and
176176
177177
return $collection;
178178
179-
.. tip::
180-
181-
Make sure you also include a default option for the ``subdomain``
182-
placeholder, otherwise you need to include the subdomains value each time
183-
you generate the route.
184-
185179
.. sidebar:: Using Service Parameters
186180

187181
You can also use service parameters if you do not want to hardcode the
188182
hostname:
189183

184+
.. tip::
185+
186+
Make sure you also include a default option for the ``subdomain``
187+
placeholder, otherwise you need to include the subdomains value each time
188+
you generate the route.
189+
190190
.. configuration-block::
191191

192192
.. code-block:: yaml
193193
194194
mobile_homepage:
195195
path: /
196196
host: "m.{domain}"
197-
defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage }
197+
defaults:
198+
_controller: AcmeDemoBundle:Main:mobileHomepage
199+
domain: "%domain%"
198200
requirements:
199201
domain: "%domain%"
200202
@@ -212,6 +214,7 @@ instance, if you want to match both ``m.example.com`` and
212214
213215
<route id="mobile_homepage" path="/" host="m.example.com">
214216
<default key="_controller">AcmeDemoBundle:Main:mobileHomepage</default>
217+
<default key="domain">%domain%</requirement>
215218
<requirement key="domain">%domain%</requirement>
216219
</route>
217220
@@ -228,6 +231,7 @@ instance, if you want to match both ``m.example.com`` and
228231
$collection = new RouteCollection();
229232
$collection->add('mobile_homepage', new Route('/', array(
230233
'_controller' => 'AcmeDemoBundle:Main:mobileHomepage',
234+
'domain' => '%domain%',
231235
), array(
232236
'domain' => '%domain% 403C ',
233237
), array(), 'm.{domain}'));

0 commit comments

Comments
 (0)
0