<?php
namespace App\Controller;
use App\Entity\Events;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class SitemapController extends AbstractController
{
/**
* @Route("/sitemap.xml", name="app_sitemap", requirements={"_format"="xml"})
*/
public function getSitemap(Request $request): Response
{
$urls = [];
$hostname = $request->getHost();
$scheme = $request->getScheme();
$urls[] = [
'loc' => $this->get('router')->generate('home'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'daily',
'priority' => '0.9',
];
$urls[] = [
'loc' => $this->get('router')->generate('hirek'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'weekly',
'priority' => '0.5',
];
$urls[] = [
'loc' => $this->get('router')->generate('istentisztelet'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'weekly',
'priority' => '0.9',
];
$istentiszteletek_results = $this->getDoctrine()->getRepository(Events::class)->getLastEvents(2, 50);
$istentisztelet_cities = [];
foreach ($istentiszteletek_results as $index => $istentisztelet) {
if ($istentisztelet->getEventType()->getId() == 2) {
$istentisztelet_cities[$istentisztelet->getCityId()->getName()] = 1;
}
}
foreach (array_keys($istentisztelet_cities) as $city) {
$urls[] = [
'loc' => $this->get('router')->generate('istentisztelet', ['varos' => $city]),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'weekly',
'priority' => '0.9',
];
}
$urls[] = [
'loc' => $this->get('router')->generate('bemutatkozas'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'weekly',
'priority' => '0.9',
];
$urls[] = [
'loc' => $this->get('router')->generate('kapcsolat'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'weekly',
'priority' => '0.9',
];
$urls[] = [
'loc' => $this->get('router')->generate('adatvedelem'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'monthly',
'priority' => '0.5',
];
$urls[] = [
'loc' => $this->get('router')->generate('impressum'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'monthly',
'priority' => '0.9',
];
$urls[] = [
'loc' => $this->get('router')->generate('napiahitatok'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'monthly',
'priority' => '0.5',
];
$urls[] = [
'loc' => $this->get('router')->generate('galleries'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'monthly',
'priority' => '0.5',
];
$urls[] = [
'loc' => $this->get('router')->generate('mediatar'),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'monthly',
'priority' => '0.5',
];
$galleries_records = $this->getDoctrine()->getRepository(Events::class)->getAllGalleries();
$galleries = [];
foreach ($galleries_records as $item) {
$galleries[$item->getId()] = 1;
}
foreach(array_keys($galleries) as $key) {
$urls[] = [
'loc' => $this->get('router')->generate('gallery_show', ['id' => $key]),
'lastmod' => date('Y-m-d\TH:i:s\Z'),
'changefreq' => 'weekly',
'priority' => '0.9',
];
}
$response = $this->render('sitemap\sitemap.xml.twig', [
'urls' => $urls,
'hostname' => $hostname,
'scheme' => $scheme,
]);
$response->headers->set('Content-Type', 'xml');
return $response;
}
/**
* @Route("/sitemap.xsl", name="app_sitemap_xsl", requirements={"_format"="xml"})
*/
public function getXsl(Request $request)
{
$response = $this->render('sitemap\sitemap.xsl.twig', []);
$response->headers->set('Content-Type', 'xml');
return $response;
}
}