File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -250,8 +250,22 @@ Annotation Routing Loaders
250
250
Last but not least there are
251
251
:class: `Symfony\\ Component\\ Routing\\ Loader\\ AnnotationDirectoryLoader ` and
252
252
: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\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
257
+ use Symfony\Component\Config\FileLocator;
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
+ // ...
255
269
256
270
.. include :: /_includes/_annotation_loader_tip.rst.inc
257
271
Original file line number Diff line number Diff line change @@ -211,6 +211,15 @@ of the service whose ID is ``admin_route_loader``. Your service doesn't have to
211
211
extend or implement any special class, but the called method must return a
212
212
:class: `Symfony\\ Component\\ Routing\\ RouteCollection ` object.
213
213
214
+ If you're using :ref: `autoconfigure <services-autoconfigure >`, your class should
215
+ implement the :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Routing\\ RouteLoaderInterface `
216
+ interface to be tagged automatically. If you're **not using autoconfigure **,
217
+ tag it manually with ``routing.route_loader ``.
218
+
219
+ .. deprecated :: 4.4
220
+
221
+ Not tagging or implementing your route loader was deprecated in Symfony 4.4.
222
+
214
223
.. note ::
215
224
216
225
The routes defined using service route loaders will be automatically
You can’t perform that action at this time.
0 commit comments