Skip to content

Commit

Permalink
Update ModuleCustomTrait.php
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
magicsunday authored Jan 7, 2021
1 parent 8091bfd commit 84ae383
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/Module/ModuleCustomTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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)) {
Expand Down

0 comments on commit 84ae383

Please sign in to comment.