public function onBeforeWrite()
 {
     parent::onBeforeWrite();
     // Make sure a valid date range is entered
     if (DateTime::createFromFormat('Y-m-d', $this->StartDate) > DateTime::createFromFormat('Y-m-d', $this->EndDate)) {
         throw new ValidationException("End date cannot occur before start date");
     }
     // Make sure something is set...
     if ($this->ShortDescription === "") {
         $this->ShortDescription = "(No description set)";
     }
     // Write the ics file for the event
     $service = new IcsGenerator($this->Title);
     $service->generateEventList(null, $this->ID);
     // Attach the file to this page
     $this->CalFileID = $service->getFileObject()->ID;
     $this->CalFileURL = $service->getFileObject()->getURL();
 }
 function setIcs20($posts)
 {
     $events20 = PostHelper::getEvents($posts, EventData::$twenty);
     $email = array_key_exists('employee', $this->emails) ? $this->emails['employee'] : '';
     $icsgen = new IcsGenerator($events20, $email, EventData::$calendarNames[0]);
     $this->events['ev20'] = $icsgen->getString();
     //var_dump($this->events);
 }