Ejemplo n.º 1
0
 public function listCalendarEvents($calendarId)
 {
     $optParams = array('maxResults' => 10, 'orderBy' => 'startTime', 'singleEvents' => TRUE, 'timeMin' => date('c'));
     $results = $this->service->events->listEvents($calendarId, $optParams);
     $events = [];
     foreach ($results->getItems() as $event) {
         $apiEvent = new ApiEntity\Event($event->getSummary(), new \DateTime('@' . strtotime($event->start->dateTime), new \DateTimeZone('Europe/Warsaw')), new \DateTime('@' . strtotime($event->end->dateTime), new \DateTimeZone('Europe/Warsaw')));
         $apiEvent->setId($event->getId());
         $apiEvent->setCreatedTime(new \DateTime('@' . strtotime($event->created), new \DateTimeZone('Europe/Warsaw')));
         $apiEvent->setDescription($event->description);
         $apiEvent->setLocation($event->location);
         $events[] = $apiEvent;
     }
     return $events;
 }