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

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.     /**
  35.      * @return string[]
  36.      */
  37.     public static function getSubscribedEvents()// : array
  38.     {
  39.         return [
  40.             SitemapPopulateEvent::ON_SITEMAP_POPULATE => 'onPopulateSitemap',
  41.         ];
  42.     }
  43.     public function onPopulateSitemap(SitemapPopulateEvent $event)
  44.     {
  45.         $container $event->getUrlContainer();
  46.         $section $event->getSection();
  47.         foreach ($this->generators as $generator) {
  48.             $generator->populate($container$section);
  49.         }
  50.     }
  51. }