Skip to content

Commit c6b4f32

Browse files
committed
use list all if no filters
1 parent 794d93c commit c6b4f32

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/Model/ListCriteria.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,20 @@ public function getViewId(): ?int
9898
public function getQueryParams(): array
9999
{
100100
$query = [];
101-
102-
if ($this->getFilters()) {
103-
$query = $this->getFilters();
104-
}
105-
if ($this->getFields()) {
106-
$query['fields'] = implode(',', $this->getFields());
107-
}
108-
if ($this->getInclude()) {
109-
$query['include'] = implode(',', $this->getInclude());
101+
$filters = $this->getFilters();
102+
103+
if ($filters) {
104+
$query = $filters;
105+
} else {
106+
if ($this->getFields()) {
107+
$query['fields'] = implode(',', $this->getFields());
108+
}
109+
if ($this->getInclude()) {
110+
$query['include'] = implode(',', $this->getInclude());
111+
}
112+
if ($this->getViewId()) {
113+
$query['viewId'] = $this->getViewId();
114+
}
110115
}
111116
if ($this->getFrom()) {
112117
$query['from'] = $this->getFrom();
@@ -117,9 +122,6 @@ public function getQueryParams(): array
117122
if ($this->getSortBy()) {
118123
$query['sortBy'] = ($this->getSortOrder() === 'DESC' ? '-' : '') . $this->getSortBy();
119124
}
120-
if ($this->getViewId()) {
121-
$query['viewId'] = $this->getViewId();
122-
}
123125

124126
return $query;
125127
}

src/Model/Operation/ListOperation.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ public function getByIds(array $entityIds): array
6565

6666
public function getList(ListCriteriaInterface $listCriteria): array
6767
{
68+
$arguments = $listCriteria->getFilters() ? array_merge(['search'], $this->arguments) : $this->arguments;
69+
6870
try {
69-
$response = $this->fetchResult(array_merge(['search'], $this->arguments), $listCriteria->getQueryParams());
71+
$response = $this->fetchResult($arguments, $listCriteria->getQueryParams());
7072
} catch (InvalidArgumentException $e) {
7173
throw new CouldNotReadException($e->getMessage(), $e->getCode(), $e);
7274
} catch (InvalidRequestException $e) {

0 commit comments

Comments
 (0)