Permalink
Browse files

feature #3368 The host parameter has to be in defaults, not requireme…

…nts (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
  • Loading branch information...
weaverryan committed Mar 27, 2014
2 parents 5a3ba1b + d552e69 commit b1e8f566a20d029f657994ae8228bb5ef7eeb5b8
Showing with 11 additions and 7 deletions.
  1. +11 −7 components/routing/hostname_pattern.rst
@@ -176,25 +176,27 @@ instance, if you want to match both ``m.example.com`` and
return $collection;
.. tip::
Make sure you also include a default option for the ``subdomain``
placeholder, otherwise you need to include the subdomains value each time
you generate the route.
.. sidebar:: Using Service Parameters
You can also use service parameters if you do not want to hardcode the
hostname:
.. tip::
Make sure you also include a default option for the ``subdomain``
placeholder, otherwise you need to include the subdomains value each time
you generate the route.
.. configuration-block::
.. code-block:: yaml
mobile_homepage:
path: /
host: "m.{domain}"
defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage }
defaults:
_controller: AcmeDemoBundle:Main:mobileHomepage
domain: "%domain%"
requirements:
domain: "%domain%"
@@ -212,6 +214,7 @@ instance, if you want to match both ``m.example.com`` and
<route id="mobile_homepage" path="/" host="m.example.com">
<default key="_controller">AcmeDemoBundle:Main:mobileHomepage</default>
<default key="domain">%domain%</requirement>
<requirement key="domain">%domain%</requirement>
</route>
@@ -228,6 +231,7 @@ instance, if you want to match both ``m.example.com`` and
$collection = new RouteCollection();
$collection->add('mobile_homepage', new Route('/', array(
'_controller' => 'AcmeDemoBundle:Main:mobileHomepage',
'domain' => '%domain%',
), array(
'domain' => '%domain%',
), array(), 'm.{domain}'));

0 comments on commit b1e8f56

Please sign in to comment.