Skip to content

Commit cb0e703

Browse files
author
Renan
committed
[Routing] Allow using services in the route condition
1 parent e7acfd9 commit cb0e703

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

routing.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,19 @@ 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`` tag to your service if you want to use it in the condition.
473+
474+
.. versionadded:: 6.1
475+
476+
The ``service(string $alias)`` function was introduced in Symfony 6.1.
477+
470478
Behind the scenes, expressions are compiled down to raw PHP. Because of this,
471479
using the ``condition`` key causes no extra overhead beyond the time it takes
472480
for the underlying PHP to execute.

0 commit comments

Comments
 (0)