8000 [Routing] Allow using services in the route condition · symfony/symfony-docs@c2478da · GitHub
[go: up one dir, main page]

Skip to content

Commit c2478da

Browse files
Renanwouterj
Renan
andcommitted
[Routing] Allow using services in the route condition
Update routing.rst Co-authored-by: Wouter de Jong <wouterj@users.noreply.github.com> Update routing.rst Co-authored-by: Wouter de Jong <wouterj@users.noreply.github.com>
1 parent fd334dd commit c2478da

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

routing.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,21 @@ and can use any of these variables created by Symfony:
462462

463463
The ``params`` variable was introduced in Symfony 6.1.
464464

465-
You can also use this function:
465+
You can also use these functions:
466466

467467
``env(string $name)``
468468
Returns the value of a variable using :doc:`Environment Variable Processors <configuration/env_var_processors>`
469469

470+
``service(string $alias)``
471+
Returns a routing condition service.
472+
You'll have to add the ``#[AsRoutingConditionService]`` attribute or ``routing.condition_service``
473+
tag to your service if you want to use it in the condition.
474+
475+
.. versionadded:: 6.1
476+
477+
The ``service(string $alias)`` function and ``#[AsRoutingConditionService]`` attribute
478+
was introduced in Symfony 6.1.
479+
470480
Behind the scenes, expressions are compiled down to raw PHP. Because of this,
471481
using the ``condition`` key causes no extra overhead beyond the time it takes
472482
for the underlying PHP to execute.

0 commit comments

Comments
 (0)
0