src/Controller/SitemapController.php line 28

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\DTO\AppDTO;
  4. use App\Service\Sitemap\Sitemap;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Contracts\Cache\CacheInterface;
  7. use Symfony\Component\HttpFoundation\Response;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. use Symfony\Component\HttpFoundation\RequestStack;
  10. class SitemapController extends AbstractASController
  11. {
  12.     protected EntityManagerInterface $em;
  13.     protected CacheInterface $Cache;
  14.     protected AppDTO $app;
  15.     //Repositories
  16.     
  17.     public function __construct(private Sitemap $sitemapRequestStack $requestStack)
  18.     {
  19.         $this->requestStack $requestStack;
  20.     }
  21.     #[Route('/sitemap'name'app_sitemap_no_locale'priority100defaults: ['_locale' => '%app.default_lang%'])]
  22.     #[Route(path'/{_locale}/sitemap'name'app_sitemap'priority100requirements: ['_locale' => '%app.langs%'])]
  23.     public function index(): Response
  24.     {
  25.         $this->sitemap->create();
  26.         $sitemap $this->sitemap->get();
  27.         $xml $this->sitemap->draw();
  28.         return new Response($xml200, ['Content-Type' => 'text/xml']);
  29.     }
  30. }