From 84ae383aed11fed9f11e010a80f2cf437257cf2e Mon Sep 17 00:00:00 2001 From: Rico Sonntag Date: Thu, 7 Jan 2021 18:11:50 +0100 Subject: [PATCH] Update ModuleCustomTrait.php Adding an additional method call to allow the processing of the response from the get latest version request. With this it would be possible for me to query the version information directly from githubs release json without the need for an exta latest-release.txt file. Using the method I could easily parse the JSON response and extract the version information. --- app/Module/ModuleCustomTrait.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/Module/ModuleCustomTrait.php b/app/Module/ModuleCustomTrait.php index c4fd1a8579c..82073705db0 100644 --- a/app/Module/ModuleCustomTrait.php +++ b/app/Module/ModuleCustomTrait.php @@ -68,6 +68,18 @@ public function customModuleLatestVersionUrl(): string return ''; } + /** + * Fetch the version information from the given content string. + * + * @param string $content + * + * @return string + */ + protected function extractVersion(string $content): string + { + return $content; + } + /** * Fetch the latest version of this module. * @@ -89,7 +101,7 @@ public function customModuleLatestVersion(): string $response = $client->get($this->customModuleLatestVersionUrl()); if ($response->getStatusCode() === StatusCodeInterface::STATUS_OK) { - $version = $response->getBody()->getContents(); + $version = $this->extractVersion($response->getBody()->getContents()); // Does the response look like a version? if (preg_match('/^\d+\.\d+\.\d+/', $version)) {