diff --git a/book/routing.rst b/book/routing.rst index 172d68dc089..3abd34f79f0 100644 --- a/book/routing.rst +++ b/book/routing.rst @@ -432,6 +432,13 @@ match, giving the ``page`` parameter a value of ``2``. Perfect. | /blog/2 | blog | {page} = 2 | +--------------------+-------+-----------------------+ +.. caution:: + + Of course, you can have more than one optional placeholder (e.g. ``/blog/{slug}/{page}``), + but everything after an optional placeholder must be optional. For example, + ``/{page}/blog`` is a valid path, but ``page`` will always be required + (i.e. simply ``/blog`` will not match this route). + .. tip:: Routes with optional parameters at the end will not match on requests diff --git a/book/translation.rst b/book/translation.rst index 840fab3baea..70a6ad87b8d 100644 --- a/book/translation.rst +++ b/book/translation.rst @@ -453,7 +453,7 @@ by the routing system using the special ``_locale`` parameter: contact: path: /{_locale}/contact - defaults: { _controller: AcmeDemoBundle:Contact:index, _locale: en } + defaults: { _controller: AcmeDemoBundle:Contact:index } requirements: _locale: en|fr|de @@ -467,7 +467,6 @@ by the routing system using the special ``_locale`` parameter: AcmeDemoBundle:Contact:index - en en|fr|de @@ -478,12 +477,15 @@ by the routing system using the special ``_locale`` parameter: use Symfony\Component\Routing\Route; $collection = new RouteCollection(); - $collection->add('contact', new Route('/{_locale}/contact', array( - '_controller' => 'AcmeDemoBundle:Contact:index', - '_locale' => 'en', - ), array( - '_locale' => 'en|fr|de', - ))); + $collection->add('contact', new Route( + '/{_locale}/contact', + array( + '_controller' => 'AcmeDemoBundle:Contact:index', + ), + array( + '_locale' => 'en|fr|de', + ) + )); return $collection;