Skip to content

Commit 26f9e3b

Browse files
committed
[book] [routing] fixed a note that wasn't properly updated
Previously, the code used the generate() method of the service and the note explained the generateUrl() method of the base controller. Then, the example was updated to use the generateUrl(), but the note kept explaining the generateUrl(). This change is just about explaining in the note the alterantive generate() method of the service.
1 parent 355cd5b commit 26f9e3b

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

book/routing.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,15 @@ route. With this information, any URL can easily be generated::
11681168

11691169
.. note::
11701170

1171-
In controllers that extend Symfony's base
1171+
In controllers that don't extend Symfony's base
11721172
:class:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller`,
1173-
you can use the
1174-
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl`
1175-
method, which calls the router service's
1176-
:method:`Symfony\\Component\\Routing\\Router::generate` method.
1173+
you can use the ``router`` service's
1174+
:method:`Symfony\\Component\\Routing\\Router::generate` method::
1175+
1176+
$url = $this->get('router')->generate(
1177+
'blog_show',
1178+
array('slug' => 'my-blog-post')
1179+
);
11771180

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

0 commit comments

Comments
 (0)