- Optimized Input class.

- Input class now returns array instead of InputItem instance when object is of type array.
- Optimized key behavior in Input class.
- Optimized arrayToParams method in RouterBase class.
- Added getMergableSettings method to RouterGroup to avoid middleware merge; as they will already be loaded.
This commit is contained in:
Simon Sessingø
2016-04-22 12:55:24 +02:00
parent 1420203149
commit 67a00c6800
3 changed files with 28 additions and 21 deletions
+11 -8
View File
@@ -303,13 +303,17 @@ class RouterBase {
}
public function arrayToParams(array $getParams = null, $includeEmpty = true) {
if (is_array($getParams) && count($getParams) > 0) {
foreach ($getParams as $key => $val) {
if (!empty($val) || $includeEmpty) {
$getParams[$key] = (is_array($val) ? $this->arrayToParams($val, $includeEmpty) : $key . '=' . $val);
}
if(is_array($getParams)) {
if ($includeEmpty === false) {
$getParams = array_filter($getParams, function ($item) {
if (!empty($item)) {
return $item;
}
});
}
return join('&', $getParams);
return http_build_query($getParams);
}
return '';
}
@@ -386,8 +390,7 @@ class RouterBase {
if($controller === null && $parameters === null) {
$getParams = (is_array($getParams)) ? array_merge($_GET, $getParams) : $_GET;
$url = parse_url(Request::getInstance()->getUri());
$url = $url['path'];
$url = parse_url($this->request->getUri(), PHP_URL_PATH);
if(count($getParams)) {
$url .= '?' . $this->arrayToParams($getParams);
+10
View File
@@ -98,4 +98,14 @@ class RouterGroup extends RouterEntry {
return $this;
}
public function getMergeableSettings() {
$settings = parent::getMergeableSettings();
if(isset($settings['middleware'])) {
unset($settings['middleware']);
}
return $settings;
}
}