location = $location; return $this; } /** * @return \Hackspace\Bundle\CalciferBundle\Entity\Location */ public function getLocation() { return $this->location; } public function isValid() { $errors = []; if (!($this->startdate instanceof \DateTime)) { $errors['startdate'] = 'Bitte gebe ein Startdatum ein.'; } if ((!is_null($this->startdate)) && (!is_null($this->enddate)) && ($this->enddate < $this->startdate)) { $errors['enddate'] = 'Bitte setze ein Enddatum das nach dem Startdatum ist.'; } if (strlen($this->summary) == 0) { $errors['summary'] = 'Bitte gebe eine Zusammenfassung an.'; } return (count($errors) > 0) ? $errors : true; } public function getFormatedDate() { $retval = $this->startdate->format('Y-m-d H:i'); if (!is_null($this->enddate)) { $retval .= " — "; if ($this->startdate->format('Y-m-d') == $this->enddate->format('Y-m-d')) { $retval .= $this->enddate->format('H:i'); } else { $retval .= $this->enddate->format('Y-m-d H:i'); } } return $retval; } public function ConvertToCalendarEvent() { $event = new CalendarEvent(); $event->setStart($this->startdate); if ($this->enddate instanceof \DateTime) $event->setEnd($this->enddate); $event->setSummary($this->summary); $event->setUrl($this->url); $event->setUid($this->id); if (count($this->tags) > 0) { $categories = []; foreach($this->tags as $tag) { $event->addCategory($tag->name); } } if ($this->location instanceof Location) { $location = new EventLocation(); $location->setName($this->location->name); $event->setLocations([$location]); if (\is_float($this->location->lon) && \is_float($this->location->lat)) { $geo = new Geo(); $geo->setLatitude($this->location->lat); $geo->setLongitude($this->location->lon); $event->setGeo($geo); } } $event->setDescription(str_replace("\r","",str_replace("\n",'\n',$this->description))); return $event; } }