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

Open in your IDE?
  1. <?php
  2. namespace Zenstruck\ScheduleBundle\EventListener;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Zenstruck\ScheduleBundle\Event\BuildScheduleEvent;
  5. use Zenstruck\ScheduleBundle\Schedule\ScheduleBuilder;
  6. /**
  7.  * @author Kevin Bond <kevinbond@gmail.com>
  8.  */
  9. final class ScheduleBuilderSubscriber implements EventSubscriberInterface
  10. {
  11.     /** @var iterable<ScheduleBuilder> */
  12.     private $builders;
  13.     /**
  14.      * @param iterable<ScheduleBuilder> $builders
  15.      */
  16.     public function __construct(iterable $builders)
  17.     {
  18.         $this->builders $builders;
  19.     }
  20.     public static function getSubscribedEvents(): array
  21.     {
  22.         return [BuildScheduleEvent::class => 'build'];
  23.     }
  24.     public function build(BuildScheduleEvent $event): void
  25.     {
  26.         foreach ($this->builders as $builder) {
  27.             $builder->buildSchedule($event->getSchedule());
  28.         }
  29.     }
  30. }