changed filter first argument to be a Twig_Environment instead of Twig_Template
authorfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Fri, 16 Oct 2009 06:55:35 +0000 (06:55 +0000)
committerfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Fri, 16 Oct 2009 06:55:35 +0000 (06:55 +0000)
git-svn-id: http://svn.twig-project.org/trunk@64 93ef8e89-cb99-4229-a87c-7fa0fa45744b

lib/Twig/Node/Expression/Filter.php
lib/Twig/runtime.php

index e835296..7109d80 100644 (file)
@@ -71,7 +71,7 @@ class Twig_Node_Expression_Filter extends Twig_Node_Expression implements Twig_N
       }
       else
       {
-        $compiler->raw($filterMap[$name][0].($filterMap[$name][1] ? '($this, ' : '('));
+        $compiler->raw($filterMap[$name][0].($filterMap[$name][1] ? '($this->getEnvironment(), ' : '('));
       }
       $postponed[] = $attrs;
     }
index d4b02c1..02b492d 100644 (file)
@@ -99,69 +99,69 @@ function twig_sort_filter($array)
   return $array;
 }
 
-function twig_escape_filter(Twig_TemplateInterface $template, $string)
+function twig_escape_filter(Twig_Environment $env, $string)
 {
   if (!is_string($string))
   {
     return $string;
   }
 
-  return htmlspecialchars($string, ENT_QUOTES, $template->getEnvironment()->getCharset());
+  return htmlspecialchars($string, ENT_QUOTES, $env->getCharset());
 }
 
 // add multibyte extensions if possible
 if (function_exists('mb_get_info'))
 {
-  function twig_upper_filter(Twig_TemplateInterface $template, $string)
+  function twig_upper_filter(Twig_Environment $env, $string)
   {
-    if (!is_null($template->getEnvironment()->getCharset()))
+    if (!is_null($env->getCharset()))
     {
-      return mb_strtoupper($string, $template->getEnvironment()->getCharset());
+      return mb_strtoupper($string, $env->getCharset());
     }
 
     return strtoupper($string);
   }
 
-  function twig_lower_filter(Twig_TemplateInterface $template, $string)
+  function twig_lower_filter(Twig_Environment $env, $string)
   {
-    if (!is_null($template->getEnvironment()->getCharset()))
+    if (!is_null($env->getCharset()))
     {
-      return mb_strtolower($string, $template->getEnvironment()->getCharset());
+      return mb_strtolower($string, $env->getCharset());
     }
 
     return strtolower($string);
   }
 
-  function twig_title_string_filter(Twig_TemplateInterface $template, $string)
+  function twig_title_string_filter(Twig_Environment $env, $string)
   {
-    if (is_null($template->getEnvironment()->getCharset()))
+    if (is_null($env->getCharset()))
     {
       return ucwords(strtolower($string));
     }
 
-    return mb_convert_case($string, MB_CASE_TITLE, $template->getEnvironment()->getCharset());
+    return mb_convert_case($string, MB_CASE_TITLE, $env->getCharset());
   }
 
-  function twig_capitalize_string_filter(Twig_TemplateInterface $template, $string)
+  function twig_capitalize_string_filter(Twig_Environment $env, $string)
   {
-    if (is_null($template->getEnvironment()->getCharset()))
+    if (is_null($env->getCharset()))
     {
       return ucfirst(strtolower($string));
     }
 
-    return mb_strtoupper(mb_substr($string, 0, 1, $template->getEnvironment()->getCharset())).
-           mb_strtolower(mb_substr($string, 1, mb_strlen($string), $template->getEnvironment()->getCharset()));
+    return mb_strtoupper(mb_substr($string, 0, 1, $env->getCharset())).
+           mb_strtolower(mb_substr($string, 1, mb_strlen($string), $env->getCharset()));
   }
 }
 // and byte fallback
 else
 {
-  function twig_title_string_filter(Twig_TemplateInterface $template, $string)
+  function twig_title_string_filter(Twig_Environment $env, $string)
   {
     return ucwords(strtolower($string));
   }
 
-  function twig_capitalize_string_filter(Twig_TemplateInterface $template, $string)
+  function twig_capitalize_string_filter(Twig_Environment $env, $string)
   {
     return ucfirst(strtolower($string));
   }