Skip to content

Commit

Permalink
[book] [routing] minor rewording and fixed some sample code
Browse files Browse the repository at this point in the history
  • Loading branch information
javiereguiluz committed Mar 30, 2014
1 parent 26f9e3b commit 7500435
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions book/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1173,10 +1173,20 @@ route. With this information, any URL can easily be generated::
you can use the ``router`` service's
:method:`Symfony\\Component\\Routing\\Router::generate` method::

$url = $this->get('router')->generate(
'blog_show',
array('slug' => 'my-blog-post')
);
use Symfony\Component\DependencyInjection\ContainerAware;

class MainController extends ContainerAware
{
public function showAction($slug)
{
// ...

$url = $this->container->get('router')->generate(
'blog_show',
array('slug' => 'my-blog-post')
);
}
}

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

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

Summary
-------
Expand Down

0 comments on commit 7500435

Please sign in to comment.