public function httpMkCalendar(RequestInterface $request, ResponseInterface $response)
    {
        $body = $request->getBodyAsString();
        $path = $request->getPath();

        $properties = [];

        if ($body) {
            try {
                $mkcalendar = $this->server->xml->expect(
                    '{urn:ietf:params:xml:ns:caldav}mkcalendar',
                    $body
                );
            } catch (\Sabre\Xml\ParseException $e) {
                throw new BadRequest($e->getMessage(), 0, $e);
            }
            $properties = $mkcalendar->getProperties();
        }

        // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored
        // subscriptions. Before that it used MKCOL which was the correct way
        // to do this.
        //
        // If the body had a {DAV:}resourcetype, it means we stumbled upon this
        // request, and we simply use it instead of the pre-defined list.
        if (isset($properties['{DAV:}resourcetype'])) {
            $resourceType = $properties['{DAV:}resourcetype']->getValue();
        } else {
            $resourceType = ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'];
        }

        $this->server->createCollection($path, new MkCol($resourceType, $properties));

        $response->setStatus(201);
        $response->setHeader('Content-Length', 0);

        // This breaks the method chain.
        return false;
    }
public function httpMkCalendar(RequestInterface $request, ResponseInterface $response)
    {
        $body = $request->getBodyAsString();
        $path = $request->getPath();

        $properties = [];

        if ($body) {
            try {
                $mkcalendar = $this->server->xml->expect(
                    '{urn:ietf:params:xml:ns:caldav}mkcalendar',
                    $body
                );
            } catch (\Sabre\Xml\ParseException $e) {
                throw new BadRequest($e->getMessage(), 0, $e);
            }
            $properties = $mkcalendar->getProperties();
        }

        // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored
        // subscriptions. Before that it used MKCOL which was the correct way
        // to do this.
        //
        // If the body had a {DAV:}resourcetype, it means we stumbled upon this
        // request, and we simply use it instead of the pre-defined list.
        if (isset($properties['{DAV:}resourcetype'])) {
            $resourceType = $properties['{DAV:}resourcetype']->getValue();
        } else {
            $resourceType = ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'];
        }

        $this->server->createCollection($path, new MkCol($resourceType, $properties));

        $response->setStatus(201);
        $response->setHeader('Content-Length', 0);

        // This breaks the method chain.
        return false;
    }
public function httpMkCalendar ( RequestInterface $ request , ResponseInterface $ response ) { $ body = $ request -> getBodyAsString ( ) ; $ path = $ request -> getPath ( ) ; $ properties = [ ] ; if ( $ body ) { try { $ mkcalendar = $ this -> server -> xml -> expect ( '{urn:ietf:params:xml:ns:caldav}mkcalendar' , $ body ) ; } catch ( \ Sabre \ Xml \ ParseException $ e ) { throw new BadRequest ( $ e -> getMessage ( ) , 0 , $ e ) ; } $ properties = $ mkcalendar -> getProperties ( ) ; } // iCal abuses MKCALENDAR since iCal 10.9.2 to create server-stored // subscriptions. Before that it used MKCOL which was the correct way // to do this. // // If the body had a {DAV:}resourcetype, it means we stumbled upon this // request, and we simply use it instead of the pre-defined list. if ( isset ( $ properties [ '{DAV:}resourcetype' ] ) ) { $ resourceType = $ properties [ '{DAV:}resourcetype' ] -> getValue ( ) ; } else { $ resourceType = [ '{DAV:}collection' , '{urn:ietf:params:xml:ns:caldav}calendar' ] ; } $ this -> server -> createCollection ( $ path , new MkCol ( $ resourceType , $ properties ) ) ; $ response -> setStatus ( 201 ) ; $ response -> setHeader ( 'Content-Length' , 0 ) ; // This breaks the method chain. return false ; }
This function handles the MKCALENDAR HTTP method, which creates
a new calendar.

@param RequestInterface  $request
@param ResponseInterface $response

@return bool
This function handles the MKCALENDAR HTTP method which creates a new calendar .