vendor/pimcore/pimcore/lib/Sitemap/EventListener/SitemapGeneratorListener.php line 48

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4.  * Pimcore
  5.  *
  6.  * This source file is available under two different licenses:
  7.  * - GNU General Public License version 3 (GPLv3)
  8.  * - Pimcore Commercial License (PCL)
  9.  * Full copyright and license information is available in
  10.  * LICENSE.md which is distributed with this source code.
  11.  *
  12.  *  @copyright  Copyright (c) Pimcore GmbH (http://www.pimcore.org)
  13.  *  @license    http://www.pimcore.org/license     GPLv3 and PCL
  14.  */
  15. namespace Pimcore\Sitemap\EventListener;
  16. use Pimcore\Sitemap\GeneratorInterface;
  17. use Presta\SitemapBundle\Event\SitemapPopulateEvent;
  18. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  19. class SitemapGeneratorListener implements EventSubscriberInterface
  20. {
  21.     /**
  22.      * @var \Iterator|GeneratorInterface[]
  23.      */
  24.     private $generators;
  25.     /**
  26.      * @param \Iterator|GeneratorInterface[] $generators
  27.      *
  28.      * TODO type hint against iterable after dropping PHP 7.0 support
  29.      */
  30.     public function __construct($generators)
  31.     {
  32.         $this->generators $generators;
  33.     }
  34.     public static function getSubscribedEvents()
  35.     {
  36.         return [
  37.             SitemapPopulateEvent::ON_SITEMAP_POPULATE => 'onPopulateSitemap',
  38.         ];
  39.     }
  40.     public function onPopulateSitemap(SitemapPopulateEvent $event)
  41.     {
  42.         $container $event->getUrlContainer();
  43.         $section $event->getSection();
  44.         foreach ($this->generators as $generator) {
  45.             $generator->populate($container$section);
  46.         }
  47.     }
  48. }