Skip to content

Commit

Permalink
feature #3368 The host parameter has to be in defaults, not requireme…
Browse files Browse the repository at this point in the history
…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 b1e8f56
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions components/routing/hostname_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand All @@ -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>
Expand All @@ -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}'));
Expand Down

0 comments on commit b1e8f56

Please sign in to comment.