Commit 87521eb3 authored by Bernhard Schussek's avatar Bernhard Schussek

Fixed pagination

parent 952ee3f7
......@@ -622,25 +622,29 @@ abstract class ORMRepository extends EntityRepository implements EditableReposit
$hasPreviousPage = $pageRequest->getPageNumber() > 0;
$hasNextPage = (($pageRequest->getPageNumber() + 1) * $pageRequest->getNumberOfItems()) < $totalCount;
$baseOffset = $pageRequest->getPageNumber() * $pageRequest->getNumberOfItems();
$items = array_map(
function ($result, int $index) use ($baseOffset) {
return new Item($result, new NumericOffset($index, $baseOffset + $index));
},
$results,
range(0, count($results) - 1)
);
$items = count($results) > 0
? array_map(
function ($result, int $index) use ($baseOffset) {
return new Item($result, new NumericOffset($index, $baseOffset + $index));
},
$results,
range(0, count($results) - 1)
)
: [];
break;
case null === $pageRequest:
$hasPreviousPage = false;
$hasNextPage = false;
$items = array_map(
function ($result, int $index) {
return new Item($result, new NumericOffset($index, $index));
},
$results,
range(0, count($results) - 1)
);
$items = count($results) > 0
? array_map(
function ($result, int $index) {
return new Item($result, new NumericOffset($index, $index));
},
$results,
range(0, count($results) - 1)
)
: [];
break;
default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment