From 7bec629be81e238091c2b297d1c632610c23d26b Mon Sep 17 00:00:00 2001 From: Julian Date: Fri, 22 Dec 2023 16:00:11 +0100 Subject: [PATCH] Add method to get all results from all pages to ResultList --- config.yaml | 2 +- lib/Client/List/ResultList.php | 20 ++++++++++++++++++++ lib/Configuration.php | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index d9b40f1..5b0247d 100644 --- a/config.yaml +++ b/config.yaml @@ -1,5 +1,5 @@ invokerPackage: Aternos\HangarApi -artifactVersion: 3.0.0 +artifactVersion: 3.1.0 generatorName: php outputDir: . sourceFolder: src diff --git a/lib/Client/List/ResultList.php b/lib/Client/List/ResultList.php index 45e10c1..a74b1ae 100644 --- a/lib/Client/List/ResultList.php +++ b/lib/Client/List/ResultList.php @@ -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 diff --git a/lib/Configuration.php b/lib/Configuration.php index 0bbcf56..db2386b 100644 --- a/lib/Configuration.php +++ b/lib/Configuration.php @@ -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) @@ -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;