Skip to content

clarify that optional placeholders can only be used at the end of a rout... #3452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 10 additions & 8 deletions book/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -467,7 +467,6 @@ by the routing system using the special ``_locale`` parameter:
<route id="contact" path="/{_locale}/contact">
<default key="_controller">AcmeDemoBundle:Contact:index</default>
<default key="_locale">en</default>
<requirement key="_locale">en|fr|de</requirement>
</route>
</routes>
Expand All @@ -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;
Expand Down