public function httpGet(RequestInterface $request, ResponseInterface $response)
    {
        $queryParams = $request->getQueryParameters();
        if (!array_key_exists('export', $queryParams)) {
            return;
        }

        $path = $request->getPath();

        $node = $this->server->getProperties($path, [
            '{DAV:}resourcetype',
            '{DAV:}displayname',
            '{http://sabredav.org/ns}sync-token',
            '{DAV:}sync-token',
            '{http://apple.com/ns/ical/}calendar-color',
        ]);

        if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{'.Plugin::NS_CALDAV.'}calendar')) {
            return;
        }
        // Marking the transactionType, for logging purposes.
        $this->server->transactionType = 'get-calendar-export';

        $properties = $node;

        $start = null;
        $end = null;
        $expand = false;
        $componentType = false;
        if (isset($queryParams['start'])) {
            if (!ctype_digit($queryParams['start'])) {
                throw new BadRequest('The start= parameter must contain a unix timestamp');
            }
            $start = DateTime::createFromFormat('U', $queryParams['start']);
        }
        if (isset($queryParams['end'])) {
            if (!ctype_digit($queryParams['end'])) {
                throw new BadRequest('The end= parameter must contain a unix timestamp');
            }
            $end = DateTime::createFromFormat('U', $queryParams['end']);
        }
        if (isset($queryParams['expand']) && (bool) $queryParams['expand']) {
            if (!$start || !$end) {
                throw new BadRequest('If you\'d like to expand recurrences, you must specify both a start= and end= parameter.');
            }
            $expand = true;
            $componentType = 'VEVENT';
        }
        if (isset($queryParams['componentType'])) {
            if (!in_array($queryParams['componentType'], ['VEVENT', 'VTODO', 'VJOURNAL'])) {
                throw new BadRequest('You are not allowed to search for components of type: '.$queryParams['componentType'].' here');
            }
            $componentType = $queryParams['componentType'];
        }

        $format = \Sabre\HTTP\negotiateContentType(
            $request->getHeader('Accept'),
            [
                'text/calendar',
                'application/calendar+json',
            ]
        );

        if (isset($queryParams['accept'])) {
            if ('application/calendar+json' === $queryParams['accept'] || 'jcal' === $queryParams['accept']) {
                $format = 'application/calendar+json';
            }
        }
        if (!$format) {
            $format = 'text/calendar';
        }

        $this->generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, $response);

        // Returning false to break the event chain
        return false;
    }
public function httpGet(RequestInterface $request, ResponseInterface $response)
    {
        $queryParams = $request->getQueryParameters();
        if (!array_key_exists('export', $queryParams)) {
            return;
        }

        $path = $request->getPath();

        $node = $this->server->getProperties($path, [
            '{DAV:}resourcetype',
            '{DAV:}displayname',
            '{http://sabredav.org/ns}sync-token',
            '{DAV:}sync-token',
            '{http://apple.com/ns/ical/}calendar-color',
        ]);

        if (!isset($node['{DAV:}resourcetype']) || !$node['{DAV:}resourcetype']->is('{'.Plugin::NS_CALDAV.'}calendar')) {
            return;
        }
        // Marking the transactionType, for logging purposes.
        $this->server->transactionType = 'get-calendar-export';

        $properties = $node;

        $start = null;
        $end = null;
        $expand = false;
        $componentType = false;
        if (isset($queryParams['start'])) {
            if (!ctype_digit($queryParams['start'])) {
                throw new BadRequest('The start= parameter must contain a unix timestamp');
            }
            $start = DateTime::createFromFormat('U', $queryParams['start']);
        }
        if (isset($queryParams['end'])) {
            if (!ctype_digit($queryParams['end'])) {
                throw new BadRequest('The end= parameter must contain a unix timestamp');
            }
            $end = DateTime::createFromFormat('U', $queryParams['end']);
        }
        if (isset($queryParams['expand']) && (bool) $queryParams['expand']) {
            if (!$start || !$end) {
                throw new BadRequest('If you\'d like to expand recurrences, you must specify both a start= and end= parameter.');
            }
            $expand = true;
            $componentType = 'VEVENT';
        }
        if (isset($queryParams['componentType'])) {
            if (!in_array($queryParams['componentType'], ['VEVENT', 'VTODO', 'VJOURNAL'])) {
                throw new BadRequest('You are not allowed to search for components of type: '.$queryParams['componentType'].' here');
            }
            $componentType = $queryParams['componentType'];
        }

        $format = \Sabre\HTTP\negotiateContentType(
            $request->getHeader('Accept'),
            [
                'text/calendar',
                'application/calendar+json',
            ]
        );

        if (isset($queryParams['accept'])) {
            if ('application/calendar+json' === $queryParams['accept'] || 'jcal' === $queryParams['accept']) {
                $format = 'application/calendar+json';
            }
        }
        if (!$format) {
            $format = 'text/calendar';
        }

        $this->generateResponse($path, $start, $end, $expand, $componentType, $format, $properties, $response);

        // Returning false to break the event chain
        return false;
    }
public function httpGet ( RequestInterface $ request , ResponseInterface $ response ) { $ queryParams = $ request -> getQueryParameters ( ) ; if ( ! array_key_exists ( 'export' , $ queryParams ) ) { return ; } $ path = $ request -> getPath ( ) ; $ node = $ this -> server -> getProperties ( $ path , [ '{DAV:}resourcetype' , '{DAV:}displayname' , '{http://sabredav.org/ns}sync-token' , '{DAV:}sync-token' , '{http://apple.com/ns/ical/}calendar-color' , ] ) ; if ( ! isset ( $ node [ '{DAV:}resourcetype' ] ) || ! $ node [ '{DAV:}resourcetype' ] -> is ( '{' . Plugin :: NS_CALDAV . '}calendar' ) ) { return ; } // Marking the transactionType, for logging purposes. $ this -> server -> transactionType = 'get-calendar-export' ; $ properties = $ node ; $ start = null ; $ end = null ; $ expand = false ; $ componentType = false ; if ( isset ( $ queryParams [ 'start' ] ) ) { if ( ! ctype_digit ( $ queryParams [ 'start' ] ) ) { throw new BadRequest ( 'The start= parameter must contain a unix timestamp' ) ; } $ start = DateTime :: createFromFormat ( 'U' , $ queryParams [ 'start' ] ) ; } if ( isset ( $ queryParams [ 'end' ] ) ) { if ( ! ctype_digit ( $ queryParams [ 'end' ] ) ) { throw new BadRequest ( 'The end= parameter must contain a unix timestamp' ) ; } $ end = DateTime :: createFromFormat ( 'U' , $ queryParams [ 'end' ] ) ; } if ( isset ( $ queryParams [ 'expand' ] ) && ( bool ) $ queryParams [ 'expand' ] ) { if ( ! $ start || ! $ end ) { throw new BadRequest ( 'If you\'d like to expand recurrences, you must specify both a start= and end= parameter.' ) ; } $ expand = true ; $ componentType = 'VEVENT' ; } if ( isset ( $ queryParams [ 'componentType' ] ) ) { if ( ! in_array ( $ queryParams [ 'componentType' ] , [ 'VEVENT' , 'VTODO' , 'VJOURNAL' ] ) ) { throw new BadRequest ( 'You are not allowed to search for components of type: ' . $ queryParams [ 'componentType' ] . ' here' ) ; } $ componentType = $ queryParams [ 'componentType' ] ; } $ format = \ Sabre \ HTTP \ negotiateContentType ( $ request -> getHeader ( 'Accept' ) , [ 'text/calendar' , 'application/calendar+json' , ] ) ; if ( isset ( $ queryParams [ 'accept' ] ) ) { if ( 'application/calendar+json' === $ queryParams [ 'accept' ] || 'jcal' === $ queryParams [ 'accept' ] ) { $ format = 'application/calendar+json' ; } } if ( ! $ format ) { $ format = 'text/calendar' ; } $ this -> generateResponse ( $ path , $ start , $ end , $ expand , $ componentType , $ format , $ properties , $ response ) ; // Returning false to break the event chain return false ; }
Intercepts GET requests on calendar urls ending with ?export.

@param RequestInterface  $request
@param ResponseInterface $response

@throws BadRequest
@throws DAV\Exception\NotFound
@throws VObject\InvalidDataException

@return bool
Intercepts GET requests on calendar urls ending with ?export .