@@ -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
11811191In 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
12711282Summary
12721283-------