public function render(Diary $diary) { $vcalendar = new VCalendar(); $vcalendar->remove('PRODID'); $vcalendar->add('PRODID', '-//Camdram//NONSGML Show Diary//EN'); foreach ($diary->getEvents() as $event) { $start_time = null; $rrule = array(); if ($event instanceof MultiDayEventInterface) { $start_time = new \DateTime($event->getStartDate()->format('Y-m-d') . ' ' . $event->getStartTime()->format('H:i:s')); $last_start_time = new \DateTime($event->getEndDate()->format('Y-m-d') . ' ' . $event->getStartTime()->format('H:i:s')); $rrule = 'FREQ=DAILY;UNTIL=' . $last_start_time->format('Ymd\\THis\\Z'); } elseif ($event instanceof SingleDayEventInterface) { $start_time = new \DateTime($event->getDate() . ' ' . $event->getStartTime()->format('H:i:s')); } if ($start_time) { $utc = new \DateTimeZone('UTC'); $start_time->setTimezone($utc); $end_time = clone $start_time; $end_time->modify('+2 hours'); $dtstamp = clone $event->getUpdatedAt(); $dtstamp->setTimezone($utc); $params = array('SUMMARY' => $event->getName(), 'LOCATION' => $event->getVenue(), 'UID' => $event->getUid(), 'DTSTAMP' => $dtstamp, 'DTSTART' => $start_time, 'DURATION' => 'PT2H00M00S', 'DESCRIPTION' => $event->getDescription()); if ($rrule) { $params['RRULE'] = $rrule; } $vcalendar->add('VEVENT', $params); } } return $vcalendar->serialize(); }
public function renderDiary(\Twig_Environment $env, Diary $diary) { return $env->render('ActsDiaryBundle:Diary:index.html.twig', array('diary' => $diary->createView())); }
/** * Gets a DiaryView, passes it to the Twig template and returns the rendered HTML as a Symfony Response object * * @param Diary $diary * * @return Response */ public function render(Diary $diary) { $view = $diary->createView(); return $this->twig->render('ActsDiaryBundle:Diary:index.html.twig', array('diary' => $view)); }