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

        if ($requestBody) {
            $contentType = $request->getHeader('Content-Type');
            if (null === $contentType || (0 !== strpos($contentType, 'application/xml') && 0 !== strpos($contentType, 'text/xml'))) {
                // We must throw 415 for unsupported mkcol bodies
                throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type');
            }

            try {
                $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody);
            } catch (\Sabre\Xml\ParseException $e) {
                throw new Exception\BadRequest($e->getMessage(), 0, $e);
            }

            $properties = $mkcol->getProperties();

            if (!isset($properties['{DAV:}resourcetype'])) {
                throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property');
            }
            $resourceType = $properties['{DAV:}resourcetype']->getValue();
            unset($properties['{DAV:}resourcetype']);
        } else {
            $properties = [];
            $resourceType = ['{DAV:}collection'];
        }

        $mkcol = new MkCol($resourceType, $properties);

        $result = $this->server->createCollection($path, $mkcol);

        if (is_array($result)) {
            $response->setStatus(207);
            $response->setHeader('Content-Type', 'application/xml; charset=utf-8');

            $response->setBody(
                $this->server->generateMultiStatus([$result])
            );
        } else {
            $response->setHeader('Content-Length', '0');
            $response->setStatus(201);
        }

        // Sending back false will interrupt the event chain and tell the server
        // we've handled this method.
        return false;
    }
public function httpMkcol(RequestInterface $request, ResponseInterface $response)
    {
        $requestBody = $request->getBodyAsString();
        $path = $request->getPath();

        if ($requestBody) {
            $contentType = $request->getHeader('Content-Type');
            if (null === $contentType || (0 !== strpos($contentType, 'application/xml') && 0 !== strpos($contentType, 'text/xml'))) {
                // We must throw 415 for unsupported mkcol bodies
                throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must have an xml Content-Type');
            }

            try {
                $mkcol = $this->server->xml->expect('{DAV:}mkcol', $requestBody);
            } catch (\Sabre\Xml\ParseException $e) {
                throw new Exception\BadRequest($e->getMessage(), 0, $e);
            }

            $properties = $mkcol->getProperties();

            if (!isset($properties['{DAV:}resourcetype'])) {
                throw new Exception\BadRequest('The mkcol request must include a {DAV:}resourcetype property');
            }
            $resourceType = $properties['{DAV:}resourcetype']->getValue();
            unset($properties['{DAV:}resourcetype']);
        } else {
            $properties = [];
            $resourceType = ['{DAV:}collection'];
        }

        $mkcol = new MkCol($resourceType, $properties);

        $result = $this->server->createCollection($path, $mkcol);

        if (is_array($result)) {
            $response->setStatus(207);
            $response->setHeader('Content-Type', 'application/xml; charset=utf-8');

            $response->setBody(
                $this->server->generateMultiStatus([$result])
            );
        } else {
            $response->setHeader('Content-Length', '0');
            $response->setStatus(201);
        }

        // Sending back false will interrupt the event chain and tell the server
        // we've handled this method.
        return false;
    }
public function httpMkcol ( RequestInterface $ request , ResponseInterface $ response ) { $ requestBody = $ request -> getBodyAsString ( ) ; $ path = $ request -> getPath ( ) ; if ( $ requestBody ) { $ contentType = $ request -> getHeader ( 'Content-Type' ) ; if ( null === $ contentType || ( 0 !== strpos ( $ contentType , 'application/xml' ) && 0 !== strpos ( $ contentType , 'text/xml' ) ) ) { // We must throw 415 for unsupported mkcol bodies throw new Exception \ UnsupportedMediaType ( 'The request body for the MKCOL request must have an xml Content-Type' ) ; } try { $ mkcol = $ this -> server -> xml -> expect ( '{DAV:}mkcol' , $ requestBody ) ; } catch ( \ Sabre \ Xml \ ParseException $ e ) { throw new Exception \ BadRequest ( $ e -> getMessage ( ) , 0 , $ e ) ; } $ properties = $ mkcol -> getProperties ( ) ; if ( ! isset ( $ properties [ '{DAV:}resourcetype' ] ) ) { throw new Exception \ BadRequest ( 'The mkcol request must include a {DAV:}resourcetype property' ) ; } $ resourceType = $ properties [ '{DAV:}resourcetype' ] -> getValue ( ) ; unset ( $ properties [ '{DAV:}resourcetype' ] ) ; } else { $ properties = [ ] ; $ resourceType = [ '{DAV:}collection' ] ; } $ mkcol = new MkCol ( $ resourceType , $ properties ) ; $ result = $ this -> server -> createCollection ( $ path , $ mkcol ) ; if ( is_array ( $ result ) ) { $ response -> setStatus ( 207 ) ; $ response -> setHeader ( 'Content-Type' , 'application/xml; charset=utf-8' ) ; $ response -> setBody ( $ this -> server -> generateMultiStatus ( [ $ result ] ) ) ; } else { $ response -> setHeader ( 'Content-Length' , '0' ) ; $ response -> setStatus ( 201 ) ; } // Sending back false will interrupt the event chain and tell the server // we've handled this method. return false ; }
WebDAV MKCOL.

The MKCOL method is used to create a new collection (directory) on the server

@param RequestInterface  $request
@param ResponseInterface $response

@return bool
WebDAV MKCOL .