vendor/zenstruck/schedule-bundle/src/EventListener/ScheduleBuilderSubscriber.php line 39

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the zenstruck/schedule-bundle package.
  4.  *
  5.  * (c) Kevin Bond <kevinbond@gmail.com>
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. namespace Zenstruck\ScheduleBundle\EventListener;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Zenstruck\ScheduleBundle\Event\BuildScheduleEvent;
  13. use Zenstruck\ScheduleBundle\Schedule\ScheduleBuilder;
  14. /**
  15.  * @author Kevin Bond <kevinbond@gmail.com>
  16.  */
  17. final class ScheduleBuilderSubscriber implements EventSubscriberInterface
  18. {
  19.     /** @var iterable<ScheduleBuilder> */
  20.     private $builders;
  21.     /**
  22.      * @param iterable<ScheduleBuilder> $builders
  23.      */
  24.     public function __construct(iterable $builders)
  25.     {
  26.         $this->builders $builders;
  27.     }
  28.     public static function getSubscribedEvents(): array
  29.     {
  30.         return [BuildScheduleEvent::class => 'build'];
  31.     }
  32.     public function build(BuildScheduleEvent $event): void
  33.     {
  34.         foreach ($this->builders as $builder) {
  35.             $builder->buildSchedule($event->getSchedule());
  36.         }
  37.     }
  38. }