getPlugins(); foreach ($plugins as $plugin) { $installed[$plugin->getId()] = $plugin; } $page = new PageSetup('menu.plugin'); $page->setHelp('plugins.html'); $all = $this->getPluginInformation($client, $cache); $bundles = []; $updates = []; foreach ($all as $item) { if ($item['bundle'] !== null) { $bundles[$item['bundle']] = $item; if (\array_key_exists($item['bundle'], $installed)) { $updates[$item['bundle']] = version_compare($installed[$item['bundle']]->getMetadata()->getVersion(), $item['latest_release']) === -1; } } } return $this->render('plugin/index.html.twig', [ 'page_setup' => $page, 'plugins' => $plugins, 'installed' => array_keys($installed), 'extensions' => $all, 'bundles' => $bundles, 'updates' => $updates, ]); } private function getPluginInformation(HttpClientInterface $client, CacheInterface $cache): array { return $cache->get('kimai.marketplace_extensions', function (ItemInterface $item) use ($client) { try { $response = $client->request('GET', 'https://www.kimai.org/plugins.json'); if ($response->getStatusCode() !== 200) { return []; } $json = json_decode($response->getContent(), true); if ($json === null) { return []; } $item->expiresAfter(86400); // one day return $response->toArray(); } catch (\Throwable $exception) { $this->logException($exception); $this->flashError('Could not download plugin information'); } return []; }); } }