From 9c305090b911dc07dd120dde33b3ae5793aaeda5 Mon Sep 17 00:00:00 2001 From: Marie Minasyan Date: Thu, 19 Dec 2013 15:55:14 +0100 Subject: [PATCH 1/2] The host parameter has to be in defaults, not requirements --- components/routing/hostname_pattern.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/routing/hostname_pattern.rst b/components/routing/hostname_pattern.rst index 38499a918d8..011e349632e 100644 --- a/components/routing/hostname_pattern.rst +++ b/components/routing/hostname_pattern.rst @@ -194,8 +194,8 @@ instance, if you want to match both ``m.example.com`` and mobile_homepage: path: / host: "m.{domain}" - defaults: { _controller: AcmeDemoBundle:Main:mobileHomepage } - requirements: + defaults: + _controller: AcmeDemoBundle:Main:mobileHomepage domain: "%domain%" homepage: @@ -212,7 +212,7 @@ instance, if you want to match both ``m.example.com`` and AcmeDemoBundle:Main:mobileHomepage - %domain% + %domain% @@ -228,8 +228,8 @@ 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', - ), array( 'domain' => '%domain%', + ), array( ), array(), 'm.{domain}')); $collection->add('homepage', new Route('/', array( From 8a1afae01c04cd7d89fefefeed62915b469c6b50 Mon Sep 17 00:00:00 2001 From: Marie Minasyan Date: Wed, 26 Mar 2014 18:42:34 +0100 Subject: [PATCH 2/2] Moved tip block to remove confusion --- components/routing/hostname_pattern.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/components/routing/hostname_pattern.rst b/components/routing/hostname_pattern.rst index 011e349632e..cf7d672be8c 100644 --- a/components/routing/hostname_pattern.rst +++ b/components/routing/hostname_pattern.rst @@ -176,17 +176,17 @@ 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 @@ -197,6 +197,8 @@ instance, if you want to match both ``m.example.com`` and defaults: _controller: AcmeDemoBundle:Main:mobileHomepage domain: "%domain%" + requirements: + domain: "%domain%" homepage: path: / @@ -213,6 +215,7 @@ instance, if you want to match both ``m.example.com`` and AcmeDemoBundle:Main:mobileHomepage %domain% + %domain% @@ -230,6 +233,7 @@ instance, if you want to match both ``m.example.com`` and '_controller' => 'AcmeDemoBundle:Main:mobileHomepage', 'domain' => '%domain%', ), array( + 'domain' => '%domain%', ), array(), 'm.{domain}')); $collection->add('homepage', new Route('/', array(