File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -379,7 +379,27 @@ You can also use these functions:
379
379
``service(string $alias) ``
380
380
Returns a routing condition service.
381
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.
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
391
+
392
+ use Symfony\Bundle\FrameworkBundle\Routing\Attribute\AsRoutingConditionService;
393
+ use Symfony\Component\HttpFoundation\Request;
394
+
395
+ #[AsRoutingConditionService(alias: 'route_checker')]
396
+ class RouteChecker
397
+ {
398
+ public function check(Request $request): bool
399
+ {
400
+ // ...
401
+ }
402
+ }
383
403
384
404
.. versionadded :: 6.1
385
405
You can’t perform that action at this time.
0 commit comments