Skip to content

Commit

Permalink
Add method to get all results from all pages to PaginatedList
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen committed Jan 9, 2024
1 parent b2f7add commit 2090e26
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/Client/List/PaginatedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,26 @@ public function getPreviousPage(): ?static
return $this->getOffset($this->getPreviousOffset());
}

/**
* Get all results from this page and all following pages.
* This will request each page from the api one by one.
*
* When called on the first page this will return all results.
*
* @throws ApiException
* @return T[]
*/
public function getResultsFromFollowingPages(): array
{
$results = $this->getResults();
$nextPage = $this->getNextPage();
while ($nextPage !== null) {
array_push($results, ...$nextPage->getResults());
$nextPage = $nextPage->getNextPage();
}
return $results;
}

/**
* @inheritDoc
* @return T
Expand Down

0 comments on commit 2090e26

Please sign in to comment.