22
33namespace G4 \Runner \Presenter \View \Twig ;
44
5+ use G4 \Runner \Presenter \DataTransfer ;
6+ use Twig \Environment ;
7+ use Twig \Loader \FilesystemLoader ;
8+
59class Template
610{
711
@@ -12,7 +16,7 @@ class Template
1216
1317 /**
1418 *
15- * @var \Twig_Environment
19+ * @var Environment
1620 */
1721 private $ templateEngine ;
1822
@@ -42,37 +46,34 @@ public function render($data, $templateName)
4246 }
4347
4448 return $ this ->getTemplateEngine ()
45- ->loadTemplate ($ templateName )
46- ->render ($ data );
49+ ->render ($ templateName , $ data );
4750 }
4851
4952 /**
50- * @return \Twig_Loader_Filesystem
53+ * @return FilesystemLoader
5154 */
5255 private function getFilesystemLoader ()
5356 {
54- return new \ Twig_Loader_Filesystem ([$ this ->templatesPath , $ this ->templatesRootPath ]);
57+ return new FilesystemLoader ([$ this ->templatesPath , $ this ->templatesRootPath ]);
5558 }
5659
5760 /**
58- * @return \Twig_Environment
61+ * @return Environment
5962 */
6063 private function getTemplateEngine ()
6164 {
62- if (!$ this ->templateEngine instanceof \Twig_Environment ) {
65+ if (!$ this ->templateEngine instanceof Environment ) {
6366 if (is_callable (['\App\DI ' , 'templateEngine ' ])) {
6467 $ this ->templateEngine = \App \DI ::templateEngine ();
65- if (!$ this ->templateEngine instanceof \Twig_Environment ) {
68+ if (!$ this ->templateEngine instanceof Environment ) {
6669 throw new \Exception ("Template engine class is invalid " );
6770 }
6871 } else {
69- $ this ->templateEngine = new \ Twig_Environment ($ this ->getFilesystemLoader (), [
72+ $ this ->templateEngine = new Environment ($ this ->getFilesystemLoader (), [
7073 'cache ' => realpath (PATH_CACHE ),
7174 'auto_reload ' => true ,
7275 'debug ' => true ,
7376 ]);
74- $ this ->templateEngine ->addExtension (new \Twig_Extensions_Extension_I18n ());
75- $ this ->templateEngine ->addExtension (new \Twig_Extension_Debug ());
7677 }
7778 }
7879
0 commit comments