Skip to content

Commit

Permalink
Add method to get all results from all pages to ResultList
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen committed Dec 22, 2023
1 parent 1f47c9e commit 7bec629
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
invokerPackage: Aternos\HangarApi
artifactVersion: 3.0.0
artifactVersion: 3.1.0
generatorName: php
outputDir: .
sourceFolder: src
Expand Down
20 changes: 20 additions & 0 deletions lib/Client/List/ResultList.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,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
4 changes: 2 additions & 2 deletions lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Configuration
*
* @var string
*/
protected $userAgent = 'OpenAPI-Generator/3.0.0/PHP';
protected $userAgent = 'OpenAPI-Generator/3.1.0/PHP';

/**
* Debug switch (default set to false)
Expand Down Expand Up @@ -433,7 +433,7 @@ public static function toDebugReport()
$report .= ' OS: ' . php_uname() . PHP_EOL;
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
$report .= ' The version of the OpenAPI document: 1.0' . PHP_EOL;
$report .= ' SDK Package Version: 3.0.0' . PHP_EOL;
$report .= ' SDK Package Version: 3.1.0' . PHP_EOL;
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;

return $report;
Expand Down

0 comments on commit 7bec629

Please sign in to comment.