Explorar o código

ZF-9295: Allow passing additional args to escape

- Allow passing more than one argument to escape() in Zend_View.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22446 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew %!s(int64=15) %!d(string=hai) anos
pai
achega
e6a734f0ef
Modificáronse 2 ficheiros con 20 adicións e 1 borrados
  1. 5 1
      library/Zend/View/Abstract.php
  2. 15 0
      tests/Zend/ViewTest.php

+ 5 - 1
library/Zend/View/Abstract.php

@@ -897,7 +897,11 @@ abstract class Zend_View_Abstract implements Zend_View_Interface
             return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_encoding);
         }
 
-        return call_user_func($this->_escape, $var);
+        if (1 == func_num_args()) {
+            return call_user_func($this->_escape, $var);
+        }
+        $args = func_get_args();
+        return call_user_func_array($this->_escape, $args);
     }
 
     /**

+ 15 - 0
tests/Zend/ViewTest.php

@@ -652,6 +652,21 @@ class Zend_ViewTest extends PHPUnit_Framework_TestCase
         $this->assertEquals("Some text", $escaped);
     }
 
+    /**
+     * @group ZF-9595
+     */
+    public function testEscapeShouldAllowAndUseMoreThanOneArgument()
+    {
+        $view = new Zend_View();
+        $view->setEscape(array($this, 'escape'));
+        $this->assertEquals('foobar', $view->escape('foo', 'bar'));
+    }
+
+    public function escape($value, $additional = '')
+    {
+        return $value . $additional;
+    }
+
     public function testZf995UndefinedPropertiesReturnNull()
     {
         error_reporting(E_ALL | E_STRICT);