@@ -27,7 +27,14 @@ class Twig
2727 'form_open ' , 'form_close ' , 'form_error ' , 'set_value ' , 'form_hidden '
2828 ];
2929
30+ /**
31+ * @var Twig_Environment
32+ */
3033 private $ twig ;
34+
35+ /**
36+ * @var Twig_Loader_Filesystem
37+ */
3138 private $ loader ;
3239
3340 public function __construct ($ params = [])
@@ -83,11 +90,23 @@ public function setLoader($loader)
8390 $ this ->loader = $ loader ;
8491 }
8592
93+ /**
94+ * Registers a Global
95+ *
96+ * @param string $name The global name
97+ * @param mixed $value The global value
98+ */
99+ public function addGlobal ($ name , $ value )
100+ {
101+ $ this ->createTwig ();
102+ $ this ->twig ->addGlobal ($ name , $ value );
103+ }
104+
86105 /**
87106 * Renders Twig Template and Set Output
88107 *
89- * @param string $view template filename without `.twig`
90- * @param array $params
108+ * @param string $view Template filename without `.twig`
109+ * @param array $params Array of parameters to pass to the template
91110 */
92111 public function display ($ view , $ params = [])
93112 {
@@ -98,8 +117,8 @@ public function display($view, $params = [])
98117 /**
99118 * Renders Twig Template and Returns as String
100119 *
101- * @param string $view template filename without `.twig`
102- * @param array $params
120+ * @param string $view Template filename without `.twig`
121+ * @param array $params Array of parameters to pass to the template
103122 * @return string
104123 */
105124 public function render ($ view , $ params = [])
@@ -157,7 +176,7 @@ private function addCIFunctions()
157176 /**
158177 * @param string $uri
159178 * @param string $title
160- * @param array $attributes [changed] only array is acceptable
179+ * @param array $attributes [changed] only array is acceptable
161180 * @return string
162181 */
163182 public function safe_anchor ($ uri = '' , $ title = '' , $ attributes = [])
@@ -179,6 +198,7 @@ public function safe_anchor($uri = '', $title = '', $attributes = [])
179198 */
180199 public function getTwig ()
181200 {
201+ $ this ->createTwig ();
182202 return $ this ->twig ;
183203 }
184204}
0 commit comments