<?php
namespace App\EventListener;
use Doctrine\Persistence\ManagerRegistry;
use Presta\SitemapBundle\Event\SitemapPopulateEvent;
use Presta\SitemapBundle\Service\UrlContainerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
abstract class AbstractSitemapSubscriber implements EventSubscriberInterface
{
protected UrlGeneratorInterface $urlGenerator;
protected ManagerRegistry $doctrine;
public function __construct(UrlGeneratorInterface $urlGenerator, ManagerRegistry $doctrine)
{
$this->urlGenerator = $urlGenerator;
$this->doctrine = $doctrine;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents(): array
{
return [
SitemapPopulateEvent::class => 'populate',
];
}
public function populate(SitemapPopulateEvent $event): void
{
$this->registerUrls($event->getUrlContainer());
}
abstract public function registerUrls(UrlContainerInterface $urls): void;
}