src/Controller/SiteMapController.php line 27

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Repository\OfferRepository;
  4. use App\Repository\SiteMapRepository;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\HttpFoundation\JsonResponse;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. class SiteMapController extends AbstractController
  10. {
  11.     /**
  12.      * @Route("/sitemap.xml", name="public_sitemap")
  13.      *
  14.      */
  15.     public function siteMap(
  16.         OfferRepository   $offerRepository,
  17.         SiteMapRepository $siteMapRepository
  18.     ): Response
  19.     {
  20.         $siteMaps $siteMapRepository->findBy(
  21.             [],
  22.             ['priority' => "DESC"]
  23.         );
  24.         $offers $offerRepository->findBy(['linkExtern' => null]);
  25.         $response $this->render("sitemap.xml.twig", [
  26.             'offers' => $offers,
  27.             'siteMaps' => $siteMaps
  28.         ]);
  29.         $response->headers->set('content-type''application/xml');
  30.         return $response;
  31.     }
  32. }