From f8a6efa4c43e2b46cd9540cfb444054cb27ecefc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 16 Sep 2022 17:11:43 +0200 Subject: [PATCH] [Twig] Document the new methods of AppVariable --- templates.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/templates.rst b/templates.rst index 1e1107e4446..0939e0616d1 100644 --- a/templates.rst +++ b/templates.rst @@ -377,6 +377,17 @@ gives you access to these variables: ``app.token`` A :class:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface` object representing the security token. +``app.current_route`` + The name of the route associated to the current request or ``null`` if no + request is available (equivalent to ``app.request.attributes.get('_route')``) +``app.current_route_parameters`` + An array with the parameters passed to the route of the current request or an + empty array if no request is available (equivalent to ``app.request.attributes.get('_route_params')``) + +.. versionadded:: 6.2 + + The ``app.current_route`` and ``app.current_route_parameters`` variables + were introduced in Symfony 6.2. In addition to the global ``app`` variable injected by Symfony, you can also :doc:`inject variables automatically to all Twig templates `.