File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
src/aleksip/DataTransformPlugin/Twig Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace aleksip \DataTransformPlugin \Twig ;
4
+
5
+ use aleksip \DataTransformPlugin \ErrorHandlerTrait ;
6
+
7
+ class TwigEnvironmentDecorator
8
+ {
9
+ use ErrorHandlerTrait;
10
+
11
+ protected $ environment ;
12
+ protected $ errno ;
13
+ protected $ errstr ;
14
+
15
+ public function __construct (\Twig_Environment $ environment )
16
+ {
17
+ $ this ->environment = $ environment ;
18
+ }
19
+
20
+ public function addGlobal ($ name , $ value )
21
+ {
22
+ $ this ->environment ->addGlobal ($ name , $ value );
23
+ }
24
+
25
+ public function render ($ name , array $ context = [])
26
+ {
27
+ $ this ->setErrorHandler ();
28
+ $ this ->environment ->render ($ name , $ context );
29
+ $ this ->restoreErrorHandler ();
30
+ }
31
+
32
+ public function __call ($ method , $ args )
33
+ {
34
+ if ($ method == 'errorHandler ' ) {
35
+ return $ this ->errorHandler (...$ args );
36
+ }
37
+ else {
38
+ return call_user_func_array ([$ this ->environment , $ method ], $ args );
39
+ }
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments