File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -378,16 +378,9 @@ You can also use these functions:
378378
379379``service(string $alias) ``
380380 Returns a routing condition service.
381- You'll have to add the ``#[AsRoutingConditionService] `` attribute or ``routing.condition_service ``
382- tag to your service if you want to use it in the condition::
383-
384-
385- // Controller (using an alias):
386- #[Route(condition: "service('route_checker').check(request)")]
387- // Or without alias:
388- #[Route(condition: "service('Ap\\\Service\\\RouteChecker').check(request)")]
389-
390- .. code-block :: php
381+
382+ First, add the ``#[AsRoutingConditionService] `` attribute or ``routing.condition_service ``
383+ tag to the services that you want to use in route conditions::
391384
392385 use Symfony\Bundle\FrameworkBundle\Routing\Attribute\AsRoutingConditionService;
393386 use Symfony\Component\HttpFoundation\Request;
@@ -401,6 +394,13 @@ You can also use these functions:
401394 }
402395 }
403396
397+ Then, use the ``service() `` function to refer to that service inside conditions::
398+
399+ // Controller (using an alias):
400+ #[Route(condition: "service('route_checker').check(request)")]
401+ // Or without alias:
402+ #[Route(condition: "service('Ap\\\Service\\\RouteChecker').check(request)")]
403+
404404.. versionadded :: 6.1
405405
406406 The ``service(string $alias) `` function and ``#[AsRoutingConditionService] ``
You can’t perform that action at this time.
0 commit comments