public function calendarMultiGetReport($report)
    {
        $needsJson = 'application/calendar+json' === $report->contentType;

        $timeZones = [];
        $propertyList = [];

        $paths = array_map(
            [$this->server, 'calculateUri'],
            $report->hrefs
        );

        foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $uri => $objProps) {
            if (($needsJson || $report->expand) && isset($objProps[200]['{'.self::NS_CALDAV.'}calendar-data'])) {
                $vObject = VObject\Reader::read($objProps[200]['{'.self::NS_CALDAV.'}calendar-data']);

                if ($report->expand) {
                    // We're expanding, and for that we need to figure out the
                    // calendar's timezone.
                    list($calendarPath) = Uri\split($uri);
                    if (!isset($timeZones[$calendarPath])) {
                        // Checking the calendar-timezone property.
                        $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
                        $tzResult = $this->server->getProperties($calendarPath, [$tzProp]);
                        if (isset($tzResult[$tzProp])) {
                            // This property contains a VCALENDAR with a single
                            // VTIMEZONE.
                            $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
                            $timeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
                        } else {
                            // Defaulting to UTC.
                            $timeZone = new DateTimeZone('UTC');
                        }
                        $timeZones[$calendarPath] = $timeZone;
                    }

                    $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $timeZones[$calendarPath]);
                }
                if ($needsJson) {
                    $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize());
                } else {
                    $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize();
                }
                // Destroy circular references so PHP will garbage collect the
                // object.
                $vObject->destroy();
            }

            $propertyList[] = $objProps;
        }

        $prefer = $this->server->getHTTPPrefer();

        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
        $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return']));
    }
public function calendarMultiGetReport($report)
    {
        $needsJson = 'application/calendar+json' === $report->contentType;

        $timeZones = [];
        $propertyList = [];

        $paths = array_map(
            [$this->server, 'calculateUri'],
            $report->hrefs
        );

        foreach ($this->server->getPropertiesForMultiplePaths($paths, $report->properties) as $uri => $objProps) {
            if (($needsJson || $report->expand) && isset($objProps[200]['{'.self::NS_CALDAV.'}calendar-data'])) {
                $vObject = VObject\Reader::read($objProps[200]['{'.self::NS_CALDAV.'}calendar-data']);

                if ($report->expand) {
                    // We're expanding, and for that we need to figure out the
                    // calendar's timezone.
                    list($calendarPath) = Uri\split($uri);
                    if (!isset($timeZones[$calendarPath])) {
                        // Checking the calendar-timezone property.
                        $tzProp = '{'.self::NS_CALDAV.'}calendar-timezone';
                        $tzResult = $this->server->getProperties($calendarPath, [$tzProp]);
                        if (isset($tzResult[$tzProp])) {
                            // This property contains a VCALENDAR with a single
                            // VTIMEZONE.
                            $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]);
                            $timeZone = $vtimezoneObj->VTIMEZONE->getTimeZone();
                        } else {
                            // Defaulting to UTC.
                            $timeZone = new DateTimeZone('UTC');
                        }
                        $timeZones[$calendarPath] = $timeZone;
                    }

                    $vObject = $vObject->expand($report->expand['start'], $report->expand['end'], $timeZones[$calendarPath]);
                }
                if ($needsJson) {
                    $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = json_encode($vObject->jsonSerialize());
                } else {
                    $objProps[200]['{'.self::NS_CALDAV.'}calendar-data'] = $vObject->serialize();
                }
                // Destroy circular references so PHP will garbage collect the
                // object.
                $vObject->destroy();
            }

            $propertyList[] = $objProps;
        }

        $prefer = $this->server->getHTTPPrefer();

        $this->server->httpResponse->setStatus(207);
        $this->server->httpResponse->setHeader('Content-Type', 'application/xml; charset=utf-8');
        $this->server->httpResponse->setHeader('Vary', 'Brief,Prefer');
        $this->server->httpResponse->setBody($this->server->generateMultiStatus($propertyList, 'minimal' === $prefer['return']));
    }
public function calendarMultiGetReport ( $ report ) { $ needsJson = 'application/calendar+json' === $ report -> contentType ; $ timeZones = [ ] ; $ propertyList = [ ] ; $ paths = array_map ( [ $ this -> server , 'calculateUri' ] , $ report -> hrefs ) ; foreach ( $ this -> server -> getPropertiesForMultiplePaths ( $ paths , $ report -> properties ) as $ uri => $ objProps ) { if ( ( $ needsJson || $ report -> expand ) && isset ( $ objProps [ 200 ] [ '{' . self :: NS_CALDAV . '}calendar-data' ] ) ) { $ vObject = VObject \ Reader :: read ( $ objProps [ 200 ] [ '{' . self :: NS_CALDAV . '}calendar-data' ] ) ; if ( $ report -> expand ) { // We're expanding, and for that we need to figure out the // calendar's timezone. list ( $ calendarPath ) = Uri \ split ( $ uri ) ; if ( ! isset ( $ timeZones [ $ calendarPath ] ) ) { // Checking the calendar-timezone property. $ tzProp = '{' . self :: NS_CALDAV . '}calendar-timezone' ; $ tzResult = $ this -> server -> getProperties ( $ calendarPath , [ $ tzProp ] ) ; if ( isset ( $ tzResult [ $ tzProp ] ) ) { // This property contains a VCALENDAR with a single // VTIMEZONE. $ vtimezoneObj = VObject \ Reader :: read ( $ tzResult [ $ tzProp ] ) ; $ timeZone = $ vtimezoneObj -> VTIMEZONE -> getTimeZone ( ) ; } else { // Defaulting to UTC. $ timeZone = new DateTimeZone ( 'UTC' ) ; } $ timeZones [ $ calendarPath ] = $ timeZone ; } $ vObject = $ vObject -> expand ( $ report -> expand [ 'start' ] , $ report -> expand [ 'end' ] , $ timeZones [ $ calendarPath ] ) ; } if ( $ needsJson ) { $ objProps [ 200 ] [ '{' . self :: NS_CALDAV . '}calendar-data' ] = json_encode ( $ vObject -> jsonSerialize ( ) ) ; } else { $ objProps [ 200 ] [ '{' . self :: NS_CALDAV . '}calendar-data' ] = $ vObject -> serialize ( ) ; } // Destroy circular references so PHP will garbage collect the // object. $ vObject -> destroy ( ) ; } $ propertyList [ ] = $ objProps ; } $ prefer = $ this -> server -> getHTTPPrefer ( ) ; $ this -> server -> httpResponse -> setStatus ( 207 ) ; $ this -> server -> httpResponse -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ this -> server -> httpResponse -> setHeader ( 'Vary' , 'Brief,Prefer' ) ; $ this -> server -> httpResponse -> setBody ( $ this -> server -> generateMultiStatus ( $ propertyList , 'minimal' === $ prefer [ 'return' ] ) ) ; }
This function handles the calendar-multiget REPORT.

This report is used by the client to fetch the content of a series
of urls. Effectively avoiding a lot of redundant requests.

@param CalendarMultiGetReport $report
This function handles the calendar - multiget REPORT .