Skip to content

Commit a3d69dd

Browse files
committed
[Routing] Invokable route loader services
1 parent 3e5d4a5 commit a3d69dd

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

routing/custom_route_loader.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ and configure the service and method to call:
9898
9999
# config/routes.yaml
100100
admin_routes:
101-
resource: 'admin_route_loader:loadRoutes'
101+
resource: 'admin_route_loader::loadRoutes'
102102
type: service
103103
104104
.. code-block:: xml
@@ -110,7 +110,7 @@ and configure the service and method to call:
110110
xsi:schemaLocation="http://symfony.com/schema/routing
111111
https://symfony.com/schema/routing/routing-1.0.xsd">
112112
113-
<import resource="admin_route_loader:loadRoutes" type="service"/>
113+
<import resource="admin_route_loader::loadRoutes" type="service"/>
114114
</routes>
115115
116116
.. code-block:: php
@@ -119,7 +119,7 @@ and configure the service and method to call:
119119
namespace Symfony\Component\Routing\Loader\Configurator;
120120
121121
return function (RoutingConfigurator $routes) {
122-
$routes->import('admin_route_loader:loadRoutes', 'service');
122+
$routes->import('admin_route_loader::loadRoutes', 'service');
123123
};
124124
125125
In this example, the routes are loaded by calling the ``loadRoutes()`` method
@@ -133,6 +133,15 @@ extend or implement any special class, but the called method must return a
133133
cached by the framework. So whenever your service should load new routes,
134134
don't forget to clear the cache.
135135

136+
.. tip::
137+
138+
If your service is invokable, you don't need to precise the method to use.
139+
140+
.. versionadded:: 4.3
141+
142+
The support of the ``__invoke()`` method to create invokable route loader
143+
services was introduced in Symfony 4.3.
144+
136145
Creating a custom Loader
137146
------------------------
138147

0 commit comments

Comments
 (0)