8000 minor #16775 [Routing] Allow using services in the route condition (r… · mpiot/symfony-docs@6a9bc50 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a9bc50

Browse files
committed
minor symfony#16775 [Routing] Allow using services in the route condition (renanbr)
This PR was merged into the 6.1 branch. Discussion ---------- [Routing] Allow using services in the route condition Documents symfony/symfony#44405 Closes symfony#16714 Commits ------- c2478da [Routing] Allow using services in the route condition
2 parents ae80e8a + c2478da commit 6a9bc50

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