Hi Evert,

Thanks for feedback. It was very helpfull.

for future reference, i'll paste the code in case anyone needs smth similar.

public function getCalendarObject($calendarId, $objectUri)
{

    $backendOrm = new Caldav_BackendOrm;
    $event = $backendOrm->getEvent($objectUri);

    if(!$event) return null;

    return [
        'id'           => $event->getObjectId(),
        'uri'          => $event->getObjectId() . '.ics',
        'lastmodified' => $event->getLastModified(),
        'etag'         => $event->getEtag(),
        'calendarid'   => $calendarId,
        'size'         => null,
        'calendardata' => $backendOrm->getVevent($event)->serialize(),
        'component'    => 'vevent',
    ];
}


class Caldav_BackendOrm
{
  public function getVevent($event)
  {

     /** @var $vCalendar create VCalendar object */
     $vCalendar = new VObject\Component\VCalendar();

     $vCalendar->add('VEVENT', [
         'SUMMARY' => $event->getEvent()->getDisplayName(),
         'DTSTART' => $event->getStartDatetime(),
         'DTEND' => $event->getEndDatetime(),
         'DTSTAMP' => $event->getStamp(),
         'UID' => $event->getEmail(),
     ]);

     /** return vCalendar object  */
     return $vCalendar;
 }
}


On Monday, November 10, 2014 10:40:12 PM UTC+1, Evert Pot wrote:
>
>
>
> On Monday, November 10, 2014 8:02:24 AM UTC-5, Milos Nikolic wrote:
>>
>>
>> Hi guys,
>>
>> I'm integrating sabredav calendar backend in my web app. I have 
>> successfully implemented auth and principal backends.
>> Now, i'm stuck at the getCalendarObject[s] methods. These methods return 
>> array of data and that part is ok, but I can't seem to figure out what am i 
>> suppose to fill calendardata attribute with?
>> what structure is expected by the caldav server?
>> Am I suppose to use vobject and pass the serialized data from vobject, or 
>> i should use array and let caldav backend format that array using vobject?
>>
>> I tried returning something like below sample, but when I click to 
>> download .ics, it is not formated like proper ical vevent.
>>
>> Do you have any advice how should I procede with implementing these to 
>> methods and formating calendardata atribute? Or any other advice based on 
>> the below mentioned code sample?
>>
>>
> Hi Milos,
>
> The calendardata key is a full-blown iCalendar file. The same type of file 
> that your calendaring software generates.
>
> You can find more information to programmatically generate these here:
> http://sabre.io/vobject/usage/
>
> I would recommend also reading the specification for iCalendar:
> https://tools.ietf.org/html/rfc5545
>
> Keep in mind that the value for "calendardata" is ultimately simply a 
> string that standards with "BEGIN:VCALENDAR".
>
> Evert
>

-- 
You received this message because you are subscribed to the Google Groups 
"SabreDAV Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sabredav-discuss/72ad8b6a-4fd5-4c3a-abe9-346546e90a39%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to