src/Controller/NavigationController.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Api\BrcBackend\BrcClient;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Response;
  6. use Symfony\Contracts\Cache\CacheInterface;
  7. use Symfony\Contracts\Cache\ItemInterface;
  8. use Psr\Cache\InvalidArgumentException;
  9. final class NavigationController extends AbstractController
  10. {
  11.     /**
  12.      * @throws InvalidArgumentException
  13.      */
  14.     public function renderCountriesNavigation(BrcClient $brcClientCacheInterface $cache): Response
  15.     {
  16.         $countries $cache->get('navigation_countries_list', function (ItemInterface $item) use ($brcClient): array {
  17.             $item->expiresAfter(86400 7);
  18.             return $brcClient->getNavigationList();
  19.         });
  20.         return $this->render('navigation/countries.html.twig', [
  21.             'countries' => $countries,
  22.         ]);
  23.     }
  24. }