Skip to content

Commit 9318d9a

Browse files
committed
Merge branch '4.4'
* 4.4: Sort imports alphabetically cleaning up some use statements, etc Update routing.rst [#11337] Added a deprecation directive [Routing] Route loader service tag
2 parents 34c6f27 + 6309eda commit 9318d9a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-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\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+
// ...
255269

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

routing/custom_route_loader.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ of the service whose ID is ``admin_route_loader``. Your service doesn't have to
211211
extend or implement any special class, but the called method must return a
212212
:class:`Symfony\\Component\\Routing\\RouteCollection` object.
213213

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+
214223
.. note::
215224

216225
The routes defined using service route loaders will be automatically

0 commit comments

Comments
 (0)