File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
src/TwigComponent/src/Twig Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,16 @@ public function compile(Compiler $compiler): void
43
43
{
44
44
$ compiler ->addDebugInfo ($ this );
45
45
46
+ // since twig/twig 3.9.0: Using the internal "twig_to_array" function is deprecated.
47
+ $ compiler
48
+ ->write ('$toArray = function ($data) { ' )
49
+ ->write ('if (method_exists(Twig\Extension\CoreExtension::class, \'toArray \')) { ' )
50
+ ->write ('return Twig\Extension\CoreExtension::toArray($data); ' )
51
+ ->write ('} ' )
52
+ ->write ('return twig_to_array($data); ' )
53
+ ->write ('}; ' )
54
+ ;
55
+
46
56
/*
47
57
* Block 1) PreCreateForRender handling
48
58
*
@@ -55,7 +65,7 @@ public function compile(Compiler $compiler): void
55
65
->raw (']->extensionPreCreateForRender( ' )
56
66
->string ($ this ->getAttribute ('component ' ))
57
67
->raw (', ' )
58
- ->raw ('twig_to_array ( ' )
68
+ ->raw ('$toArray ( ' )
59
69
;
60
70
$ this ->writeProps ($ compiler )
61
71
->raw (') ' )
@@ -86,7 +96,7 @@ public function compile(Compiler $compiler): void
86
96
->string (ComponentExtension::class)
87
97
->raw (']->startEmbeddedComponentRender( ' )
88
98
->string ($ this ->getAttribute ('component ' ))
89
- ->raw (', twig_to_array ( ' )
99
+ ->raw (', $toArray ( ' )
90
100
;
91
101
$ this ->writeProps ($ compiler )
92
102
->raw ('), ' )
You can’t perform that action at this time.
0 commit comments