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

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. /**
  14.  * @author Kevin Bond <kevinbond@gmail.com>
  15.  */
  16. final class ScheduleExtensionSubscriber implements EventSubscriberInterface
  17. {
  18.     /** @var iterable<object> */
  19.     private $extensions;
  20.     /**
  21.      * @param iterable<object> $extensions
  22.      */
  23.     public function __construct(iterable $extensions)
  24.     {
  25.         $this->extensions $extensions;
  26.     }
  27.     public static function getSubscribedEvents(): array
  28.     {
  29.         return [BuildScheduleEvent::class => 'addExtensions'];
  30.     }
  31.     public function addExtensions(BuildScheduleEvent $event): void
  32.     {
  33.         foreach ($this->extensions as $extension) {
  34.             $event->getSchedule()->addExtension($extension);
  35.         }
  36.     }
  37. }