Skip to content

Commit f8b8e0d

Browse files
Some fixes and rewords
1 parent 5ec506d commit f8b8e0d

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

routing/external_resources.rst

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -134,30 +134,40 @@ The path of each route being loaded from the new routing resource will now
134134
be prefixed with the string ``/site``.
135135

136136
Prefixing the Names of Imported Routes
137-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138-
You have the possibility to prefix all routes names with the ``@Route`` annotation.
139-
Add a ``name`` property to the ``@Route`` annotation of the controller class and that will be considered the prefix of all route names
140-
141-
.. code-block:: php
142-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
143-
144-
/**
145-
* @Route("/blog", name="blog_")
146-
*/
147-
class BlogController extends Controller
148-
{
149-
/**
150-
* @Route("/", defaults={"page": "1"}, name="index")
151-
* @Route("/page/{page}", name="index_paginated")
152-
*/
153-
public function indexAction($page, $_format) { ... }
154-
155-
/**
156-
* @Route("/posts/{slug}", name="post")
157-
*/
158-
public function showAction(Post $post) { ... }
159-
}
160-
137+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138+
139+
.. versionadded:: 3.4
140+
The feature to prefix route names was introduced in Symfony 3.4.
141+
142+
You also have the possibility to prefix all route names defined in a controller
143+
class with the ``name`` attribute of the ``@Route`` annotation::
144+
145+
use Symfony\Component\Routing\Annotation\Route;
146+
147+
/**
148+
* @Route(name="blog_")
149+
*/
150+
class BlogController extends Controller
151+
{
152+
/**
153+
* @Route("/blog", name="index")
154+
*/
155+
public function indexAction()
156+
{
157+
// ...
158+
}
159+
160+
/**
161+
* @Route("/blog/posts/{slug}", name="post")
162+
*/
163+
public function showAction(Post $post)
164+
{
165+
// ...
166+
}
167+
}
168+
169+
In this example, the names of the routes will be ``blog_index`` and ``blog_post``.
170+
161171
Adding a Host Requirement to Imported Routes
162172
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
163173

0 commit comments

Comments
 (0)