Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcf4022e

Browse files
committed
[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.
1 parent296a0a0 commitcf4022e

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

‎routing.rst‎

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,13 +256,13 @@ expressions - see :doc:`/routing/requirements`.
256256
Giving {placeholders} a Default Value
257257
-------------------------------------
258258

259-
In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If the
260-
usergoes to``/blog/1``, it will match. But ifthe user goes to``/blog``, it will
261-
**not** match. As soon as you add a ``{placeholder}`` to a route, it *must* have
262-
a value.
259+
In the previous example, the ``blog_list`` has a path of ``/blog/{page}``. If
260+
theuservisits``/blog/1``, it will match. But ifthey visit``/blog``, it
261+
will**not** match. As soon as you add a ``{placeholder}`` to a route, it
262+
*must* havea value.
263263

264-
So how canwe make ``/blog_list`` once again match when the usergoes to ``/blog``?
265-
By adding a *default* value:
264+
So how canyou make ``blog_list`` once again match when the uservisits
265+
``/blog``?By adding a *default* value:
266266

267267
..configuration-block::
268268

@@ -309,6 +309,7 @@ By adding a *default* value:
309309
<routeid="blog_list"path="/blog/{page}">
310310
<defaultkey="_controller">AppBundle:Blog:list</default>
311311
<defaultkey="page">1</default>
312+
312313
<requirementkey="page">\d+</requirement>
313314
</route>
314315
@@ -322,19 +323,23 @@ By adding a *default* value:
322323
use Symfony\Component\Routing\Route;
323324
324325
$collection = new RouteCollection();
325-
$collection->add('blog_list', new Route('/blog/{page}', array(
326-
'_controller' => 'AppBundle:Blog:list',
327-
'page' => 1,
328-
), array(
329-
'page' => '\d+'
330-
)));
326+
$collection->add('blog_list', new Route(
327+
'/blog/{page}',
328+
array(
329+
'_controller' => 'AppBundle:Blog:list',
330+
'page' => 1,
331+
),
332+
array(
333+
'page' => '\d+'
334+
)
335+
));
331336
332337
// ...
333338
334339
return $collection;
335340
336-
Now, when the usergoes to``/blog``, the ``blog_list`` route will match and ``$page``
337-
will default to a value of ``1``.
341+
Now, when the uservisits``/blog``, the ``blog_list`` route will match and
342+
``$page``will default to a value of ``1``.
338343

339344
..index::
340345
single: Routing; Advanced example

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp