vendor/zenstruck/schedule-bundle/src/EventListener/ScheduleExtensionSubscriber.php line 29

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