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

Appearance settings

Commit 7500435

Browse filesBrowse files
committed
[book] [routing] minor rewording and fixed some sample code
1 parent 26f9e3b commit 7500435
Copy full SHA for 7500435

File tree

Expand file treeCollapse file tree

1 file changed

+16
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+16
-5
lines changed

‎book/routing.rst

Copy file name to clipboardExpand all lines: book/routing.rst
+16-5Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.