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:
378
378
379
379
``service(string $alias) ``
380
380
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::
391
384
392
385
use Symfony\Bundle\FrameworkBundle\Routing\Attribute\AsRoutingConditionService;
393
386
use Symfony\Component\HttpFoundation\Request;
@@ -401,6 +394,13 @@ You can also use these functions:
401
394
}
402
395
}
403
396
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
+
404
404
.. versionadded :: 6.1
405
405
406
406
The ``service(string $alias) `` function and ``#[AsRoutingConditionService] ``
You can’t perform that action at this time.
0 commit comments