To add an event to a calendar the event's calendar ID has to be set manually
Just intuitively using the following code does not work:
$Event = new Event($title, $startDateTimeObjekt, $endDateTimeObjekt);
$Calendar->addEvent($Event);
You have to do the following:
$Event = new Event($title, $startDateTimeObjekt, $endDateTimeObjekt);
$Event->setCalendarId($Calendar->getId());
$Calendar->addEvent($Event);
Having to do this makes no sense and over complicates things.
The addEvent
-method should set the Event's calendar id if it's not set yet.