11
11
12
12
namespace App \Twig ;
13
13
14
+ use Twig \Environment ;
15
+ use Twig \Extension \AbstractExtension ;
16
+ use Twig \Template ;
17
+ use Twig \TwigFunction ;
18
+
14
19
/**
15
20
* CAUTION: this is an extremely advanced Twig extension. It's used to get the
16
21
* source code of the controller and the template used to render the current
20
25
* @author Ryan Weaver <[email protected] >
21
26
* @author Javier Eguiluz <[email protected] >
22
27
*/
23
- class SourceCodeExtension extends \Twig_Extension
28
+ class SourceCodeExtension extends AbstractExtension
24
29
{
25
30
private $ controller ;
26
31
@@ -35,11 +40,11 @@ public function setController($controller)
35
40
public function getFunctions ()
36
41
{
37
42
return [
38
- new \ Twig_SimpleFunction ('show_source_code ' , [$ this , 'showSourceCode ' ], ['is_safe ' => ['html ' ], 'needs_environment ' => true ]),
43
+ new TwigFunction ('show_source_code ' , [$ this , 'showSourceCode ' ], ['is_safe ' => ['html ' ], 'needs_environment ' => true ]),
39
44
];
40
45
}
41
46
42
- public function showSourceCode (\ Twig_Environment $ twig , $ template )
47
+ public function showSourceCode (Environment $ twig , $ template )
43
48
{
44
49
return $ twig ->render ('debug/source_code.html.twig ' , [
45
50
'controller ' => $ this ->getController (),
@@ -91,7 +96,7 @@ private function getCallableReflector($callable)
91
96
return new \ReflectionFunction ($ callable );
92
97
}
93
98
94
- private function getTemplateSource (\ Twig_Template $ template )
99
+ private function getTemplateSource (Template $ template )
95
100
{
96
101
$ templateSource = $ template ->getSourceContext ();
97
102
0 commit comments