<?php
namespace App\EventSubscriber;
use CalendarBundle\CalendarEvents;
use CalendarBundle\Entity\Event;
use CalendarBundle\Event\CalendarEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class CalendarSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
CalendarEvents::SET_DATA => 'onCalendarSetData',
];
}
public function onCalendarSetData(CalendarEvent $calendar)
{
$bookingEvent = new Event(
'Event 1',
new \DateTime('Tuesday this week')
);
$bookingEvent->setAllDay(true);
$bookingEvent->setOptions([
'backgroundColor' => 'red',
'borderColor' => 'red',
]);
$calendar->addEvent($bookingEvent);
}
}