From cf4022e6af78c0dbb75d7d464d3de6772dac9843 Mon Sep 17 00:00:00 2001 From: WouterJ Date: Sun, 21 Aug 2016 12:05:18 +0200 Subject: [PATCH] [Routing] Some minor tweaks to the placeholder doc * Replaced "goes to" with "visits"; * Removed wrong `/` at the end of a route name (it was confused with an actual URI); * Reindented the PHP example to be more readable. --- routing.rst | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/routing.rst b/routing.rst index f4e5a4c47f3..b6440dacc5d 100644 --- a/routing.rst +++ b/routing.rst @@ -256,13 +256,13 @@ expressions - see :doc:`/routing/requirements`. Giving {placeholders} a Default Value ------------------------------------- -In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If the -user goes to ``/blog/1``, it will match. But if the user goes to ``/blog``, it will -**not** match. As soon as you add a ``{placeholder}`` to a route, it *must* have -a value. +In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If +the user visits ``/blog/1``, it will match. But if they visit ``/blog``, it +will **not** match. As soon as you add a ``{placeholder}`` to a route, it +*must* have a value. -So how can we make ``/blog_list`` once again match when the user goes to ``/blog``? -By adding a *default* value: +So how can you make ``blog_list`` once again match when the user visits +``/blog``? By adding a *default* value: .. configuration-block:: @@ -309,6 +309,7 @@ By adding a *default* value: AppBundle:Blog:list 1 + \d+ @@ -322,19 +323,23 @@ By adding a *default* value: use Symfony\Component\Routing\Route; $collection = new RouteCollection(); - $collection->add('blog_list', new Route('/blog/{page}', array( - '_controller' => 'AppBundle:Blog:list', - 'page' => 1, - ), array( - 'page' => '\d+' - ))); + $collection->add('blog_list', new Route( + '/blog/{page}', + array( + '_controller' => 'AppBundle:Blog:list', + 'page' => 1, + ), + array( + 'page' => '\d+' + ) + )); // ... return $collection; -Now, when the user goes to ``/blog``, the ``blog_list`` route will match and ``$page`` -will default to a value of ``1``. +Now, when the user visits ``/blog``, the ``blog_list`` route will match and +``$page`` will default to a value of ``1``. .. index:: single: Routing; Advanced example