From f8cdec56b46726205fd52b658c9e55209cb3ec40 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 fcbe74718bb..3939aab461e 100644 --- a/app/Module/ModuleCustomTrait.php +++ b/app/Module/ModuleCustomTrait.php @@ -82,6 +82,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. * @@ -103,7 +115,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)) {