diff --git a/web/landing/src/Flow/Website/Controller/FlowController.php b/web/landing/src/Flow/Website/Controller/FlowController.php index 6d2d51c8c..77e016625 100644 --- a/web/landing/src/Flow/Website/Controller/FlowController.php +++ b/web/landing/src/Flow/Website/Controller/FlowController.php @@ -19,8 +19,7 @@ public function __construct(private readonly Github $github) public function main() : Response { return $this->render('main/changelog.html.twig', [ - 'changelog_markdown' => file_get_contents($this->getParameter('flow_root_dir') . '/CHANGELOG.md'), + 'changelog_markdown' => \file_get_contents($this->getParameter('flow_root_dir') . '/CHANGELOG.md'), ]); } - -} \ No newline at end of file +} diff --git a/web/landing/src/Flow/Website/Controller/LayoutController.php b/web/landing/src/Flow/Website/Controller/LayoutController.php index 4e52993a6..1d366e7f1 100644 --- a/web/landing/src/Flow/Website/Controller/LayoutController.php +++ b/web/landing/src/Flow/Website/Controller/LayoutController.php @@ -28,4 +28,4 @@ public function hero() : Response 'version' => $this->github->version('flow-php/flow'), ]); } -} \ No newline at end of file +} diff --git a/web/landing/src/Flow/Website/Service/Github.php b/web/landing/src/Flow/Website/Service/Github.php index 18c729cd2..4f343fc44 100644 --- a/web/landing/src/Flow/Website/Service/Github.php +++ b/web/landing/src/Flow/Website/Service/Github.php @@ -29,35 +29,6 @@ public function __construct( ) { } - public function version(string $project) : string - { - $cache = $this->cache('flow-github-version'); - - if ($cache->has('version')) { - return $cache->get('version'); - } - - $factory = new Psr17Factory(); - $client = new Client($factory, $factory); - - $request = $factory - ->createRequest('GET', 'https://api.github.com/repos/flow-php/flow/releases/latest') - ->withHeader('Accept', 'application/vnd.github+json') - ->withHeader('Authorization', 'Bearer ' . $this->requestFactory->githubToken) - ->withHeader('X-GitHub-Api-Version', '2022-11-28') - ->withHeader('User-Agent', 'flow-website-fetch'); - - $response = $client->sendRequest($request); - - $data = \json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); - - $version = $data['tag_name']; - - $cache->set('version', $version); - - return $version; - } - public function contributors() : array { $factory = new Psr17Factory(); @@ -96,7 +67,36 @@ public function contributors() : array } } - private function cache(string $directoryName): Psr16Cache + public function version(string $project) : string + { + $cache = $this->cache('flow-github-version'); + + if ($cache->has('version')) { + return $cache->get('version'); + } + + $factory = new Psr17Factory(); + $client = new Client($factory, $factory); + + $request = $factory + ->createRequest('GET', 'https://api.github.com/repos/flow-php/flow/releases/latest') + ->withHeader('Accept', 'application/vnd.github+json') + ->withHeader('Authorization', 'Bearer ' . $this->requestFactory->githubToken) + ->withHeader('X-GitHub-Api-Version', '2022-11-28') + ->withHeader('User-Agent', 'flow-website-fetch'); + + $response = $client->sendRequest($request); + + $data = \json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR); + + $version = $data['tag_name']; + + $cache->set('version', $version); + + return $version; + } + + private function cache(string $directoryName) : Psr16Cache { return new Psr16Cache( new FilesystemAdapter(