src/EventSubscriber/CalendarSubscriber.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use CalendarBundle\CalendarEvents;
  4. use CalendarBundle\Entity\Event;
  5. use CalendarBundle\Event\CalendarEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class CalendarSubscriber implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents()
  10.     {
  11.         return [
  12.             CalendarEvents::SET_DATA => 'onCalendarSetData',
  13.         ];
  14.     }
  15.     public function onCalendarSetData(CalendarEvent $calendar)
  16.     {
  17.         $bookingEvent = new Event(
  18.             'Event 1',
  19.             new \DateTime('Tuesday this week')
  20.         );
  21.         $bookingEvent->setAllDay(true);
  22.         $bookingEvent->setOptions([
  23.             'backgroundColor' => 'red',
  24.             'borderColor' => 'red',
  25.         ]);
  26.         $calendar->addEvent($bookingEvent);
  27.     }
  28. }