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

Commit7500435

Browse files
committed
[book] [routing] minor rewording and fixed some sample code
1 parent26f9e3b commit7500435

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

‎book/routing.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,10 +1173,20 @@ route. With this information, any URL can easily be generated::
11731173
you can use the ``router`` service's
11741174
:method:`Symfony\\Component\\Routing\\Router::generate` method::
11751175

1176-
$url = $this->get('router')->generate(
1177-
'blog_show',
1178-
array('slug' => 'my-blog-post')
1179-
);
1176+
use Symfony\Component\DependencyInjection\ContainerAware;
1177+
1178+
class MainController extends ContainerAware
1179+
{
1180+
public function showAction($slug)
1181+
{
1182+
// ...
1183+
1184+
$url = $this->container->get('router')->generate(
1185+
'blog_show',
1186+
array('slug' => 'my-blog-post')
1187+
);
1188+
}
1189+
}
11801190

11811191
In an upcoming section, you'll learn how to generate URLs from inside templates.
11821192

@@ -1266,7 +1276,8 @@ From a template, it looks like this:
12661276
The host that's used when generating an absolute URL is automatically
12671277
detected using the current ``Request`` object. When generating absolute
12681278
URLs from outside the web context (for instance in a console command) this
1269-
won't work. See:doc:`/cookbook/console/sending_emails` for details.
1279+
doesn't work. See:doc:`/cookbook/console/sending_emails` to learn how to
1280+
solve this problem.
12701281

12711282
Summary
12721283
-------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp