feat(SiteMapListener): Ajoute les URLs des formules de réservation au sitemap.

This commit is contained in:
Serreau Jovann
2026-01-28 10:06:18 +01:00
parent aa75f290d0
commit 5462e2ac65

View File

@@ -3,6 +3,7 @@
namespace App\Security;
use App\Entity\Product;
use App\Repository\FormulesRepository;
use App\Repository\OptionsRepository;
use App\Repository\ProductRepository;
use Doctrine\ORM\EntityManagerInterface;
@@ -22,6 +23,7 @@ class SiteMapListener implements EventSubscriberInterface
private readonly UploaderHelper $uploaderHelper,
private readonly OptionsRepository $optionsRepository,
private readonly ProductRepository $productRepository,
private readonly FormulesRepository $formulesRepository,
private readonly EntityManagerInterface $entityManager
) {
}
@@ -105,6 +107,25 @@ class SiteMapListener implements EventSubscriberInterface
$workFlow = new UrlConcrete($reservationUrl, $t, UrlConcrete::CHANGEFREQ_MONTHLY, 0.5);
$urlContainer->addUrl($workFlow, 'reservation');
foreach ($this->formulesRepository->findBy(['isPublish'=>true]) as $formule) {
$formulesUrls = $urlGenerator->generate(
'reservation_formule_show',
['id' => $formule->slug()],
UrlGeneratorInterface::ABSOLUTE_URL
);
$decoratedUrl = new GoogleImageUrlDecorator(
new UrlConcrete($formulesUrls, $formule->getUpdatedAt(), UrlConcrete::CHANGEFREQ_WEEKLY, 0.5)
);
$imagePath = $this->uploaderHelper->asset($formule, 'imageFile');
if ($imagePath) {
$usedList = [];
// Appel de votre fonction avec l'objet product
$this->addImageToSitemap($decoratedUrl, $usedList, $rootUrl, $imagePath, $formule);
}
$urlContainer->addUrl($decoratedUrl, 'reservation_formules');
}
// --- 2. PRODUITS & IMAGES ---
foreach ($this->productRepository->findAll() as $product) {
$productUrl = $urlGenerator->generate(