Fixed Grav\Framework\Route::__toString() returning relative URL, not relative route

This commit is contained in:
Matias Griese
2019-01-23 10:55:32 +02:00
parent 5b0e2e401e
commit 52c7d8dfb7
2 changed files with 15 additions and 4 deletions

View File

@@ -24,6 +24,7 @@
* Fixed issue with `redirect_trailing_slash` losing query string [#2269](https://github.com/getgrav/grav/issues/2269)
* Fixed failed login if user attempts to log in with upper case non-english letters
* Removed extra authenticated/authorized fields when saving existing user from a form
* Fixed `Grav\Framework\Route::__toString()` returning relative URL, not relative route
# v1.6.0-beta.7
## 12/14/2018

View File

@@ -259,11 +259,12 @@ class Route
}
/**
* @param bool $includeRoot
* @return string
*/
public function __toString()
public function toString(bool $includeRoot = false)
{
$url = $this->getUriPath();
$url = $this->getUriPath($includeRoot);
if ($this->queryParams) {
$url .= '?' . $this->getUriQuery();
@@ -272,6 +273,14 @@ class Route
return $url;
}
/**
* @return string
*/
public function __toString()
{
return $this->toString();
}
/**
* @param string $type
* @param string $param
@@ -297,11 +306,12 @@ class Route
}
/**
* @param bool $includeRoot
* @return string
*/
protected function getUriPath()
protected function getUriPath($includeRoot = false)
{
$parts = [$this->root];
$parts = $includeRoot ? [$this->root] : [''];
if ($this->language !== '') {
$parts[] = $this->language;