Browse Source

Restore img and allow use twig dump in templates

Angel Fernando Quiroz Campos 7 years ago
parent
commit
c144e0714c
1 changed files with 9 additions and 3 deletions
  1. 9 3
      main/inc/lib/template.lib.php

+ 9 - 3
main/inc/lib/template.lib.php

@@ -94,8 +94,10 @@ class Template
 
         $loader = new Twig_Loader_Filesystem($template_paths);
 
+        $isTestMode = api_get_setting('server_type') === 'test';
+
         //Setting Twig options depending on the server see http://twig.sensiolabs.org/doc/api.html#environment-options
-        if (api_get_setting('server_type') == 'test') {
+        if ($isTestMode) {
             $options = array(
                 //'cache' => api_get_path(SYS_ARCHIVE_PATH), //path to the cache folder
                 'autoescape' => false,
@@ -122,6 +124,10 @@ class Template
 
         $this->twig = new Twig_Environment($loader, $options);
 
+        if ($isTestMode) {
+            $this->twig->addExtension(new Twig_Extension_Debug());
+        }
+
         // Twig filters setup
         $filters = [
             'get_plugin_lang',
@@ -158,8 +164,8 @@ class Template
                 'callable' => 'Template::format_date'
             ],
             [
-                'name' => 'icon',
-                'callable' => 'Template::get_icon_path'
+                'name' => 'img',
+                'callable' => 'Template::get_image'
             ]
         ];