当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::createCollection方法代码示例

本文整理汇总了PHP中Sabre\DAV\Server::createCollection方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::createCollection方法的具体用法?PHP Server::createCollection怎么用?PHP Server::createCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sabre\DAV\Server的用法示例。


在下文中一共展示了Server::createCollection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: httpMkCalendar

 /**
  * This function handles the MKCALENDAR HTTP method, which creates
  * a new calendar.
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 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(), null, $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));
     $this->server->httpResponse->setStatus(201);
     $this->server->httpResponse->setHeader('Content-Length', 0);
     // This breaks the method chain.
     return false;
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:38,代码来源:Plugin.php

示例2: httpMkcol

    /**
     * WebDAV MKCOL
     *
     * The MKCOL method is used to create a new collection (directory) on the server
     *
     * @param RequestInterface $request
     * @param ResponseInterface $response
     * @return bool
     */
    function httpMkcol(RequestInterface $request, ResponseInterface $response) {

        $requestBody = $request->getBodyAsString();
        $path = $request->getPath();

        if ($requestBody) {

            $contentType = $request->getHeader('Content-Type');
            if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) {

                // 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(), null, $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 interupt the event chain and tell the server
        // we've handled this method.
        return false;

    }
开发者ID:nikosv,项目名称:openeclass,代码行数:67,代码来源:CorePlugin.php

示例3: browserPostAction

 /**
  * This method allows us to intercept the 'mkcalendar' sabreAction. This
  * action enables the user to create new calendars from the browser plugin.
  *
  * @param string $uri
  * @param string $action
  * @param array $postVars
  * @return bool
  */
 function browserPostAction($uri, $action, array $postVars)
 {
     if ($action !== 'mkcalendar') {
         return;
     }
     $resourceType = ['{DAV:}collection', '{urn:ietf:params:xml:ns:caldav}calendar'];
     $properties = [];
     if (isset($postVars['{DAV:}displayname'])) {
         $properties['{DAV:}displayname'] = $postVars['{DAV:}displayname'];
     }
     $this->server->createCollection($uri . '/' . $postVars['name'], $resourceType, $properties);
     return false;
 }
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:22,代码来源:Plugin.php

示例4: httpMkcol

 /**
  * WebDAV MKCOL
  *
  * The MKCOL method is used to create a new collection (directory) on the server
  *
  * @param RequestInterface $request
  * @param ResponseInterface $response
  * @return bool
  */
 function httpMkcol(RequestInterface $request, ResponseInterface $response)
 {
     $requestBody = $request->getBodyAsString();
     $path = $request->getPath();
     if ($requestBody) {
         $contentType = $request->getHeader('Content-Type');
         if (strpos($contentType, 'application/xml') !== 0 && strpos($contentType, 'text/xml') !== 0) {
             // 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');
         }
         $dom = XMLUtil::loadDOMDocument($requestBody);
         if (XMLUtil::toClarkNotation($dom->firstChild) !== '{DAV:}mkcol') {
             // We must throw 415 for unsupported mkcol bodies
             throw new Exception\UnsupportedMediaType('The request body for the MKCOL request must be a {DAV:}mkcol request construct.');
         }
         $properties = [];
         foreach ($dom->firstChild->childNodes as $childNode) {
             if (XMLUtil::toClarkNotation($childNode) !== '{DAV:}set') {
                 continue;
             }
             $properties = array_merge($properties, XMLUtil::parseProperties($childNode, $this->server->propertyMap));
         }
         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'];
     }
     $result = $this->server->createCollection($path, $resourceType, $properties);
     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 interupt the event chain and tell the server
     // we've handled this method.
     return false;
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:53,代码来源:CorePlugin.php


注:本文中的Sabre\DAV\Server::createCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。