8000 minor #15495 [Twig] Global variable in TwigConfig should be passed by… · Tobion/symfony-docs@318466c · GitHub
[go: up one dir, main page]

Skip to content

Commit 318466c

Browse files
committed
minor symfony#15495 [Twig] Global variable in TwigConfig should be passed by service function (tugmaks)
This PR was merged into the 5.3 branch. Discussion ---------- [Twig] Global variable in TwigConfig should be passed by service function Commits ------- a8177db Global variable in TwigConfig should be passed by service function
2 parents 3fc3914 + a8177db commit 318466c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

templating/global_variables.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,12 @@ the ``@`` character, which is the usual syntax to
100100
101101
// config/packages/twig.php
102102
use Symfony\Config\TwigConfig;
103+
use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
103104
104105
return static function (TwigConfig $twig) {
105106
// ...
106107
107-
$twig->global('uuid')->value('@App\Generator\UuidGenerator');
108+
$twig->global('uuid')->value(service('App\Generator\UuidGenerator'));
108109
};
109110
110111
Now you can use the ``uuid`` variable in any Twig template to access to the

0 commit comments

Comments
 (0)
0