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

Commit91f6bd0

Browse files
committed
minor#10201 [Routing] Update routing.rst, add example routes as annotations (andreybolonin, weaverryan)
This PR was submitted for the 4.1 branch but it was merged into the 4.3 branch instead (closes#10201).Discussion----------[Routing] Update routing.rst, add example routes as annotations<!--If your pull request fixes a BUG, use the oldest maintained branch that containsthe bug (seehttps://symfony.com/roadmap for the list of maintained branches).If your pull request documents a NEW FEATURE, use the same Symfony branch wherethe feature was introduced (and `master` for features of unreleased versions).-->Commits-------54743d6 cleaning up some use statements, etc0a1badf Update routing.rst
2 parents076478c +54743d6 commit91f6bd0

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

‎components/routing.rst‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,22 @@ Annotation Routing Loaders
250250
Last but not least there are
251251
:class:`Symfony\\Component\\Routing\\Loader\\AnnotationDirectoryLoader` and
252252
:class:`Symfony\\Component\\Routing\\Loader\\AnnotationFileLoader` to load
253-
route definitions from class annotations. The specific details are left
254-
out here.
253+
route definitions from class annotations::
254+
255+
use Doctrine\Common\Annotations\AnnotationReader;
256+
use Symfony\Component\Config\FileLocator;
257+
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
258+
use Symfony\Component\Routing\Loader\AnnotationDirectoryLoader;
259+
260+
$loader = new AnnotationDirectoryLoader(
261+
new FileLocator(__DIR__.'/app/controllers/'),
262+
new AnnotatedRouteControllerLoader(
263+
new AnnotationReader()
264+
)
265+
);
266+
267+
$routes = $loader->load(__DIR__.'/app/controllers/');
268+
// ...
255269

256270
..include::/_includes/_annotation_loader_tip.rst.inc
257271

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp