Skip to content

Commit 23a875e

Browse files
committed
Enable ->params
1 parent d6b95bb commit 23a875e

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/data/Pagination.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class Pagination
7474
*
7575
* @var array
7676
*/
77-
public $params;
77+
public $params = [];
7878

7979
/**
8080
* Total number of items
@@ -183,8 +183,10 @@ public function createUrl($page, $perPage=null)
183183
if ($this->perPageParam) {
184184
$params[$this->perPageParam] = ($perPage) ? $perPage : $this->perPage;
185185
}
186+
// Verify $this->params
187+
$this->params = is_array($this->params) ? $this->params : [];
186188
// Build URL
187-
$url = "//{$_SERVER['HTTP_HOST']}{$requestUri}?" . http_build_query(array_merge($_GET, $params));
189+
$url = "//{$_SERVER['HTTP_HOST']}{$requestUri}?" . http_build_query(array_merge($_GET, $this->params, $params));
188190

189191
return $url;
190192
}

test/test.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
$pagination = new \yidas\data\Pagination([
99
'totalCount' => $count,
10+
'params' => [
11+
'key' => 'value',
12+
],
1013
]);
1114

1215
?>

0 commit comments

Comments
 (0)