浏览代码

[HttpFoundation] added a way to generate a URI based on the current one and a path

Fabien Potencier 14 年之前
父节点
当前提交
94347f73c5
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      src/Symfony/Component/HttpFoundation/Request.php

+ 12 - 0
src/Symfony/Component/HttpFoundation/Request.php

@@ -374,6 +374,18 @@ class Request
         return $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getScriptName().$this->getPathInfo().$qs;
         return $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getScriptName().$this->getPathInfo().$qs;
     }
     }
 
 
+    /**
+     * Generates a normalized URI for the given path.
+     *
+     * @param string $path A path to use instead of the current one
+     *
+     * @return string The normalized URI for the path
+     */
+    public function getUriForPath($path)
+    {
+        return $this->getScheme().'://'.$this->getHost().':'.$this->getPort().$this->getScriptName().$path;
+    }
+
     /**
     /**
      * Generates the normalized query string for the Request.
      * Generates the normalized query string for the Request.
      *
      *