src/EventSubscriber/CalendarSubscriber.php line 28
<?phpnamespace App\EventSubscriber;use App\Repository\ProjetRepository;use CalendarBundle\CalendarEvents;use CalendarBundle\Entity\Event;use CalendarBundle\Event\CalendarEvent;use Symfony\Component\EventDispatcher\EventSubscriberInterface;class CalendarSubscriber implements EventSubscriberInterface{private ProjetRepository $projetRepository;public function __construct(ProjetRepository $projetRepository){$this->projetRepository = $projetRepository;}public static function getSubscribedEvents(): array{return [CalendarEvents::SET_DATA => 'onCalendarSetData',];}public function onCalendarSetData(CalendarEvent $calendar){$start = $calendar->getStart();$end = $calendar->getEnd();$filters = $calendar->getFilters();// You may want to make a custom query from your database to fill the calendar$projets = $this->projetRepository->findAll();foreach ($projets as $projet) {$debut = $projet->getRendezVousAt();$event = new Event($projet,$debut,$debut->add(new \DateInterval('PT30M')));$event->setOptions(['backgroundColor' => '#FF0000','borderColor' => '#FF0000',]);$calendar->addEvent($event);// $event = new Event(// $projet,// $debut,// $debut->add(new \DateInterval('PT30M'))// );}}}