Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitbcb4076

Browse files
committed
minor#9186 add Prefixing the Names of Imported Routes (ismail1432, javiereguiluz)
This PR was merged into the 3.4 branch.Discussion----------add Prefixing the Names of Imported RoutesThis PR follows this one#9159Commits-------f8b8e0d Some fixes and rewords5ec506d add Prefixing the Names of Imported Routes
2 parents3137a73 +f8b8e0d commitbcb4076

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

‎routing/external_resources.rst‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,41 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
133133
The path of each route being loaded from the new routing resource will now
134134
be prefixed with the string ``/site``.
135135

136+
Prefixing the Names of Imported Routes
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+
136171
Adding a Host Requirement to Imported Routes
137172
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138173

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp