Example #1
0
 /**
  * @return array|\it\thecsea\caldav_client_adapter\EventInterface[]
  * @throws \it\thecsea\caldav_client_adapter\CaldavException
  * @throws \Illuminate\Contracts\Encryption\DecryptException
  * @throws CaldavException
  */
 private function getEvents()
 {
     //TODO catch php errors like array key
     $caldavClient = new SimpleCaldavAdapter();
     $caldavClient->connect($this->calendar->url, $this->calendar->username, \Crypt::decrypt($this->calendar->password));
     $calendars = $caldavClient->findCalendars();
     if (!isset($calendars[$this->calendar->calendar_name])) {
         throw new CaldavException("calendar inserted doesn't exist");
     }
     $caldavClient->setCalendar($calendars[$this->calendar->calendar_name]);
     /**
      * 26 hours before to avoid tiemezone problems and dst problems
      * 30 days after
      */
     return $caldavClient->getEvents(date('Ymd\\THis\\Z', time() - 93600), date('Ymd\\THis\\Z', time() + 2592000));
 }