Merge pull request #50 from skipperbent/development

Development
This commit is contained in:
Simon Sessingø
2015-12-11 18:23:53 +01:00
+13 -9
View File
@@ -219,13 +219,16 @@ class RouterBase {
return $this; return $this;
} }
protected function getParamsToArray($query) { public function arrayToParams(array $getParams = null, $includeEmpty = true) {
$output = array(); if (is_array($getParams) && count($getParams) > 0) {
if($query[0] === '?') { foreach ($getParams as $key => $val) {
$query = substr($query, 1); if (!empty($val) || empty($val) && $includeEmpty) {
$getParams[$key] = $key . '=' . $val;
}
}
return join('&', $getParams);
} }
parse_str($query, $output); return '';
return $output;
} }
protected function processUrl($route, $method = null, $parameters = null, $getParams = null) { protected function processUrl($route, $method = null, $parameters = null, $getParams = null) {
@@ -261,7 +264,7 @@ class RouterBase {
$url = rtrim($url, '/') . '/'; $url = rtrim($url, '/') . '/';
if($getParams !== null && count($getParams)) { if($getParams !== null && count($getParams)) {
$url .= '?' . $this->getParamsToArray($getParams); $url .= '?' . $this->arrayToParams($getParams);
} }
return $url; return $url;
@@ -342,8 +345,9 @@ class RouterBase {
$url = '/' . trim(join('/', $url), '/') . '/'; $url = '/' . trim(join('/', $url), '/') . '/';
if(is_array($getParams)) {
$url .= '?' . $this->getParamsToArray($getParams); if($getParams !== null && count($getParams)) {
$url .= '?' . $this->arrayToParams($getParams);
} }
return $url; return $url;