<?php
namespace App\Controller;
use App\Api\BrcBackend\BrcClient;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
use Psr\Cache\InvalidArgumentException;
final class NavigationController extends AbstractController
{
/**
* @throws InvalidArgumentException
*/
public function renderCountriesNavigation(BrcClient $brcClient, CacheInterface $cache): Response
{
$countries = $cache->get('navigation_countries_list', function (ItemInterface $item) use ($brcClient): array {
$item->expiresAfter(86400 * 7);
return $brcClient->getNavigationList();
});
return $this->render('navigation/countries.html.twig', [
'countries' => $countries,
]);
}
}