public function mergeObjects(array $properties, array $inputObjects)
    {
        $calendar = new VObject\Component\VCalendar();
        $calendar->VERSION = '2.0';
        if (DAV\Server::$exposeVersion) {
            $calendar->PRODID = '-//SabreDAV//SabreDAV '.DAV\Version::VERSION.'//EN';
        } else {
            $calendar->PRODID = '-//SabreDAV//SabreDAV//EN';
        }
        if (isset($properties['{DAV:}displayname'])) {
            $calendar->{'X-WR-CALNAME'} = $properties['{DAV:}displayname'];
        }
        if (isset($properties['{http://apple.com/ns/ical/}calendar-color'])) {
            $calendar->{'X-APPLE-CALENDAR-COLOR'} = $properties['{http://apple.com/ns/ical/}calendar-color'];
        }

        $collectedTimezones = [];

        $timezones = [];
        $objects = [];

        foreach ($inputObjects as $href => $inputObject) {
            $nodeComp = VObject\Reader::read($inputObject);

            foreach ($nodeComp->children() as $child) {
                switch ($child->name) {
                    case 'VEVENT':
                    case 'VTODO':
                    case 'VJOURNAL':
                        $objects[] = clone $child;
                        break;

                    // VTIMEZONE is special, because we need to filter out the duplicates
                    case 'VTIMEZONE':
                        // Naively just checking tzid.
                        if (in_array((string) $child->TZID, $collectedTimezones)) {
                            break;
                        }

                        $timezones[] = clone $child;
                        $collectedTimezones[] = $child->TZID;
                        break;
                }
            }
            // Destroy circular references to PHP will GC the object.
            $nodeComp->destroy();
            unset($nodeComp);
        }

        foreach ($timezones as $tz) {
            $calendar->add($tz);
        }
        foreach ($objects as $obj) {
            $calendar->add($obj);
        }

        return $calendar;
    }
public function mergeObjects(array $properties, array $inputObjects)
    {
        $calendar = new VObject\Component\VCalendar();
        $calendar->VERSION = '2.0';
        if (DAV\Server::$exposeVersion) {
            $calendar->PRODID = '-//SabreDAV//SabreDAV '.DAV\Version::VERSION.'//EN';
        } else {
            $calendar->PRODID = '-//SabreDAV//SabreDAV//EN';
        }
        if (isset($properties['{DAV:}displayname'])) {
            $calendar->{'X-WR-CALNAME'} = $properties['{DAV:}displayname'];
        }
        if (isset($properties['{http://apple.com/ns/ical/}calendar-color'])) {
            $calendar->{'X-APPLE-CALENDAR-COLOR'} = $properties['{http://apple.com/ns/ical/}calendar-color'];
        }

        $collectedTimezones = [];

        $timezones = [];
        $objects = [];

        foreach ($inputObjects as $href => $inputObject) {
            $nodeComp = VObject\Reader::read($inputObject);

            foreach ($nodeComp->children() as $child) {
                switch ($child->name) {
                    case 'VEVENT':
                    case 'VTODO':
                    case 'VJOURNAL':
                        $objects[] = clone $child;
                        break;

                    // VTIMEZONE is special, because we need to filter out the duplicates
                    case 'VTIMEZONE':
                        // Naively just checking tzid.
                        if (in_array((string) $child->TZID, $collectedTimezones)) {
                            break;
                        }

                        $timezones[] = clone $child;
                        $collectedTimezones[] = $child->TZID;
                        break;
                }
            }
            // Destroy circular references to PHP will GC the object.
            $nodeComp->destroy();
            unset($nodeComp);
        }

        foreach ($timezones as $tz) {
            $calendar->add($tz);
        }
        foreach ($objects as $obj) {
            $calendar->add($obj);
        }

        return $calendar;
    }
public function mergeObjects ( array $ properties , array $ inputObjects ) { $ calendar = new VObject \ Component \ VCalendar ( ) ; $ calendar -> VERSION = '2.0' ; if ( DAV \ Server :: $ exposeVersion ) { $ calendar -> PRODID = '-//SabreDAV//SabreDAV ' . DAV \ Version :: VERSION . '//EN' ; } else { $ calendar -> PRODID = '-//SabreDAV//SabreDAV//EN' ; } if ( isset ( $ properties [ '{DAV:}displayname' ] ) ) { $ calendar -> { 'X-WR-CALNAME' } = $ properties [ '{DAV:}displayname' ] ; } if ( isset ( $ properties [ '{http://apple.com/ns/ical/}calendar-color' ] ) ) { $ calendar -> { 'X-APPLE-CALENDAR-COLOR' } = $ properties [ '{http://apple.com/ns/ical/}calendar-color' ] ; } $ collectedTimezones = [ ] ; $ timezones = [ ] ; $ objects = [ ] ; foreach ( $ inputObjects as $ href => $ inputObject ) { $ nodeComp = VObject \ Reader :: read ( $ inputObject ) ; foreach ( $ nodeComp -> children ( ) as $ child ) { switch ( $ child -> name ) { case 'VEVENT' : case 'VTODO' : case 'VJOURNAL' : $ objects [ ] = clone $ child ; break ; // VTIMEZONE is special, because we need to filter out the duplicates case 'VTIMEZONE' : // Naively just checking tzid. if ( in_array ( ( string ) $ child -> TZID , $ collectedTimezones ) ) { break ; } $ timezones [ ] = clone $ child ; $ collectedTimezones [ ] = $ child -> TZID ; break ; } } // Destroy circular references to PHP will GC the object. $ nodeComp -> destroy ( ) ; unset ( $ nodeComp ) ; } foreach ( $ timezones as $ tz ) { $ calendar -> add ( $ tz ) ; } foreach ( $ objects as $ obj ) { $ calendar -> add ( $ obj ) ; } return $ calendar ; }
Merges all calendar objects, and builds one big iCalendar blob.

@param array $properties   Some CalDAV properties
@param array $inputObjects

@return VObject\Component\VCalendar
Merges all calendar objects and builds one big iCalendar blob .