Skip to content

Commit bcda539

Browse files
committed
Allow all Pager queries by default
1 parent 135f701 commit bcda539

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/Model.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,9 @@ abstract class Model implements ModelInterface
167167
*/
168168
protected string $pagerQuery;
169169
/**
170-
* @var array<string>
170+
* @var array<string>|null
171171
*/
172-
protected array $pagerAllowedQueries;
172+
protected array | null $pagerAllowedQueries = null;
173173
/**
174174
* Pager URL.
175175
*
@@ -537,10 +537,7 @@ protected function setPager(Pager $pager) : static
537537
if (isset($temp)) {
538538
$pager->setUrl($temp);
539539
}
540-
$temp = $this->getPagerAllowedQueries();
541-
if (isset($temp)) {
542-
$pager->setAllowedQueries($temp);
543-
}
540+
$pager->setAllowedQueries($this->getPagerAllowedQueries());
544541
$temp = $this->getPagerView();
545542
if (isset($temp)) {
546543
$pager->setDefaultView($temp);
@@ -586,7 +583,7 @@ protected function getPagerQuery() : ?string
586583
*/
587584
protected function getPagerAllowedQueries() : ?array
588585
{
589-
return $this->pagerAllowedQueries ?? null;
586+
return $this->pagerAllowedQueries;
590587
}
591588

592589
/**

tests/ModelMock.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ModelMock extends Model
2424
public string $pagerView;
2525
public string $pagerUrl;
2626
public string $pagerQuery;
27-
public array $pagerAllowedQueries;
27+
public array | null $pagerAllowedQueries = null;
2828

2929
public function convertCase(string $value, string $case) : string
3030
{

tests/ModelTest.php

+5
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,11 @@ public function testPagerQuery() : void
542542
public function testPagerAllowedQueries() : void
543543
{
544544
$_SERVER['REQUEST_URI'] = '/products?page=5&foo=bar&order=asc&bla=bla&per_page=10';
545+
$this->model->paginate(5);
546+
self::assertSame(
547+
'http://localhost:8080/products?page=5&foo=bar&order=asc&bla=bla&per_page=10',
548+
$this->model->getPager()->getCurrentPageUrl()
549+
);
545550
$this->model->pagerAllowedQueries = ['order', 'per_page'];
546551
$this->model->paginate(5);
547552
self::assertSame(

0 commit comments

Comments
 (0)