<?php
namespace App\Controller;
use App\Repository\ArticleRepository;
use App\Repository\PhotoAlbumRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class SitemapController extends AbstractController
{
/**
* @Route("/sitemap.xml", name="sitemap", defaults={"_format"="xml"})
*/
public function sitemap(
ArticleRepository $articleRepo,
PhotoAlbumRepository $albumRepo
): Response {
$articles = $articleRepo->findBy(['isActive' => true]);
$albums = $albumRepo->findBy(['isActive' => true]);
$response = $this->render('sitemap.xml.twig', [
'articles' => $articles,
'albums' => $albums,
]);
$response->headers->set('Content-Type', 'application/xml; charset=UTF-8');
return $response;
}
}