Selaa lähdekoodia

ZF-3681
Zend_Controller
Defined constant URI_DELIMITER in Zend_Controller_Router_Route_Abstract
Updated individual route classes to use URI_DELIMITER


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24179 44c647ce-9c0f-0410-b52a-842ac1e357ba

adamlundrigan 14 vuotta sitten
vanhempi
commit
304ad8a68e

+ 5 - 0
library/Zend/Controller/Router/Route/Abstract.php

@@ -38,6 +38,11 @@ require_once 'Zend/Controller/Router/Route/Interface.php';
 abstract class Zend_Controller_Router_Route_Abstract implements Zend_Controller_Router_Route_Interface
 {
     /**
+     * URI delimiter
+     */
+    const URI_DELIMITER = '/';
+    
+    /**
      * Wether this route is abstract or not
      *
      * @var boolean

+ 2 - 2
library/Zend/Controller/Router/Route/Chain.php

@@ -54,7 +54,7 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
      * @param  string                                $separator
      * @return Zend_Controller_Router_Route_Chain
      */
-    public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/')
+    public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = self::URI_DELIMITER)
     {
         $this->_routes[]     = $route;
         $this->_separators[] = $separator;
@@ -72,7 +72,7 @@ class Zend_Controller_Router_Route_Chain extends Zend_Controller_Router_Route_Ab
      */
     public function match($request, $partial = null)
     {
-        $path    = trim($request->getPathInfo(), '/');
+        $path    = trim($request->getPathInfo(), self::URI_DELIMITER);
         $subPath = $path;
         $values  = array();
 

+ 7 - 12
library/Zend/Controller/Router/Route/Module.php

@@ -37,11 +37,6 @@ require_once 'Zend/Controller/Router/Route/Abstract.php';
 class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_Abstract
 {
     /**
-     * URI delimiter
-     */
-    const URI_DELIMITER = '/';
-
-    /**
      * Default values for the route (ie. module, controller, action, params)
      * @var array
      */
@@ -237,29 +232,29 @@ class Zend_Controller_Router_Route_Module extends Zend_Controller_Router_Route_A
             if (is_array($value)) {
                 foreach ($value as $arrayValue) {
                     $arrayValue = ($encode) ? urlencode($arrayValue) : $arrayValue;
-                    $url .= '/' . $key;
-                    $url .= '/' . $arrayValue;
+                    $url .= self::URI_DELIMITER . $key;
+                    $url .= self::URI_DELIMITER . $arrayValue;
                 }
             } else {
                 if ($encode) $value = urlencode($value);
-                $url .= '/' . $key;
-                $url .= '/' . $value;
+                $url .= self::URI_DELIMITER . $key;
+                $url .= self::URI_DELIMITER . $value;
             }
         }
 
         if (!empty($url) || $action !== $this->_defaults[$this->_actionKey]) {
             if ($encode) $action = urlencode($action);
-            $url = '/' . $action . $url;
+            $url = self::URI_DELIMITER . $action . $url;
         }
 
         if (!empty($url) || $controller !== $this->_defaults[$this->_controllerKey]) {
             if ($encode) $controller = urlencode($controller);
-            $url = '/' . $controller . $url;
+            $url = self::URI_DELIMITER . $controller . $url;
         }
 
         if (isset($module)) {
             if ($encode) $module = urlencode($module);
-            $url = '/' . $module . $url;
+            $url = self::URI_DELIMITER . $module . $url;
         }
 
         return ltrim($url, self::URI_DELIMITER);

+ 1 - 1
library/Zend/Controller/Router/Route/Regex.php

@@ -74,7 +74,7 @@ class Zend_Controller_Router_Route_Regex extends Zend_Controller_Router_Route_Ab
     public function match($path, $partial = false)
     {
         if (!$partial) {
-            $path = trim(urldecode($path), '/');
+            $path = trim(urldecode($path), self::URI_DELIMITER);
             $regex = '#^' . $this->_regex . '$#i';
         } else {
             $regex = '#^' . $this->_regex . '#i';