diff options
Diffstat (limited to 'lib/private/App/AppStore/Fetcher/Fetcher.php')
-rw-r--r-- | lib/private/App/AppStore/Fetcher/Fetcher.php | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/private/App/AppStore/Fetcher/Fetcher.php b/lib/private/App/AppStore/Fetcher/Fetcher.php index cffff9176e2..f82e1a253f6 100644 --- a/lib/private/App/AppStore/Fetcher/Fetcher.php +++ b/lib/private/App/AppStore/Fetcher/Fetcher.php @@ -30,11 +30,11 @@ abstract class Fetcher { const INVALIDATE_AFTER_SECONDS = 300; /** @var IAppData */ - private $appData; + protected $appData; /** @var IClientService */ - private $clientService; + protected $clientService; /** @var ITimeFactory */ - private $timeFactory; + protected $timeFactory; /** @var string */ protected $fileName; /** @var string */ @@ -54,6 +54,20 @@ abstract class Fetcher { } /** + * Fetches the response from the server + * + * @return array + */ + protected function fetch() { + $client = $this->clientService->newClient(); + $response = $client->get($this->endpointUrl); + $responseJson = []; + $responseJson['data'] = json_decode($response->getBody(), true); + $responseJson['timestamp'] = $this->timeFactory->getTime(); + return $responseJson; + } + + /** * Returns the array with the categories on the appstore server * * @return array @@ -77,12 +91,8 @@ abstract class Fetcher { } // Refresh the file content - $client = $this->clientService->newClient(); try { - $response = $client->get($this->endpointUrl); - $responseJson = []; - $responseJson['data'] = json_decode($response->getBody(), true); - $responseJson['timestamp'] = $this->timeFactory->getTime(); + $responseJson = $this->fetch(); $file->putContent(json_encode($responseJson)); return json_decode($file->getContent(), true)['data']; } catch (\Exception $e) { |