src/EventListener/AbstractSitemapSubscriber.php line 32

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Doctrine\Persistence\ManagerRegistry;
  4. use Presta\SitemapBundle\Event\SitemapPopulateEvent;
  5. use Presta\SitemapBundle\Service\UrlContainerInterface;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  8. abstract class AbstractSitemapSubscriber implements EventSubscriberInterface
  9. {
  10.     protected UrlGeneratorInterface $urlGenerator;
  11.     protected ManagerRegistry $doctrine;
  12.     public function __construct(UrlGeneratorInterface $urlGeneratorManagerRegistry $doctrine)
  13.     {
  14.         $this->urlGenerator $urlGenerator;
  15.         $this->doctrine $doctrine;
  16.     }
  17.     /**
  18.      * {@inheritdoc}
  19.      */
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         return [
  23.             SitemapPopulateEvent::class => 'populate',
  24.         ];
  25.     }
  26.     public function populate(SitemapPopulateEvent $event): void
  27.     {
  28.         $this->registerUrls($event->getUrlContainer());
  29.     }
  30.     abstract public function registerUrls(UrlContainerInterface $urls): void;
  31. }