Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a flag to Router::reverse that is passed on to the Router::url …

…call

Fixes #1638

Signed-off-by: mark_story <mark@mark-story.com>
  • Loading branch information...
commit 3675e73c73038d05171b64670132118d9ef44105 1 parent 011aeae
Joey Trapp authored markstory committed
View
6 lib/Cake/Routing/Router.php
@@ -1013,9 +1013,11 @@ public static function queryString($q, $extra = array(), $escape = false) {
* are used for CakePHP internals and should not normally be part of an output url.
*
* @param mixed $param The params array or CakeRequest object that needs to be reversed.
+ * @param boolean $full Set to true to include the full url including the protocol when reversing
+ * the url.
* @return string The string that is the reversed result of the array
*/
- public static function reverse($params) {
+ public static function reverse($params, $full = false) {
if ($params instanceof CakeRequest) {
$url = $params->query;
$params = $params->params;
@@ -1033,7 +1035,7 @@ public static function reverse($params) {
if (!empty($url)) {
$params['?'] = $url;
}
- return Router::url($params);
+ return Router::url($params, $full);
}
/**
View
11 lib/Cake/tests/Case/Routing/RouterTest.php
@@ -2327,6 +2327,17 @@ function testRouterReverse() {
$result = Router::reverse($request);
$expected = '/eng/posts/view/1?test=value';
$this->assertEquals($expected, $result);
+
+ $params = array(
+ 'lang' => 'eng',
+ 'controller' => 'posts',
+ 'action' => 'view',
+ 'pass' => array(1),
+ 'named' => array(),
+ 'url' => array('url' => 'eng/posts/view/1')
+ );
+ $result = Router::reverse($params, true);
+ $this->assertPattern('/^http(s)?:\/\//', $result);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.