فهرست منبع

Twig_Loader_String is now deprecated - https://github.com/jonnnnyw/php-phantomjs/issues/84

Jonny Wenmoth 9 سال پیش
والد
کامیت
a0b32700c8

+ 1 - 1
src/JonnyW/PhantomJs/Resources/config/config.yml

@@ -52,7 +52,7 @@ parameters:
     phantomjs.template.template_renderer.class: JonnyW\PhantomJs\Template\TemplateRenderer
     phantomjs.twig.environment.class: Twig_Environment
     phantomjs.twig.lexer.class: Twig_Lexer
-    phantomjs.twig.string_loader.class: Twig_Loader_String
+    phantomjs.twig.array_loader.class: Twig_Loader_Array
 
 ##################
 ### RESOURCES ####

+ 6 - 4
src/JonnyW/PhantomJs/Resources/config/services.yml

@@ -128,11 +128,13 @@ services:
     phantomjs.twig.environment:
         class: "%phantomjs.twig.environment.class%"
         arguments:
-            - "@phantomjs.twig.string_loader"
+            - "@phantomjs.twig.array_loader"
         public: false
 
-    phantomjs.twig.string_loader:
-        class: "%phantomjs.twig.string_loader.class%"
+    phantomjs.twig.array_loader:
+        class: "%phantomjs.twig.array_loader.class%"
+        arguments:
+            - []
         public: false
 
     phantomjs.procedure.template_renderer:
@@ -144,7 +146,7 @@ services:
     phantomjs.procedure.twig.environment:
         class: "%phantomjs.twig.environment.class%"
         arguments:
-            - "@phantomjs.twig.string_loader"
+            - "@phantomjs.twig.array_loader"
         public: false
         calls:
             - [ "setLexer", [ "@phantomjs.procedure.twig.lexer" ] ]

+ 3 - 1
src/JonnyW/PhantomJs/Template/TemplateRenderer.php

@@ -44,6 +44,8 @@ class TemplateRenderer implements TemplateRendererInterface
      */
     public function render($template, array $context = array())
     {
-        return $this->twig->render($template, $context);
+        $template = $this->twig->createTemplate($template);
+
+        return $template->render($context);
     }
 }