當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Server::checkPreconditions方法代碼示例

本文整理匯總了PHP中Sabre\DAV\Server::checkPreconditions方法的典型用法代碼示例。如果您正苦於以下問題:PHP Server::checkPreconditions方法的具體用法?PHP Server::checkPreconditions怎麽用?PHP Server::checkPreconditions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sabre\DAV\Server的用法示例。


在下文中一共展示了Server::checkPreconditions方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: beforeMethod

 /**
  * This event is triggered before any HTTP request is handled.
  *
  * We use this to intercept GET calls to notification nodes, and return the
  * proper response.
  *
  * @param string $method
  * @param string $path
  * @return void
  */
 public function beforeMethod($method, $path)
 {
     if ($method !== 'GET') {
         return;
     }
     try {
         $node = $this->server->tree->getNodeForPath($path);
     } catch (DAV\Exception\NotFound $e) {
         return;
     }
     if (!$node instanceof Notifications\INode) {
         return;
     }
     if (!$this->server->checkPreconditions(true)) {
         return false;
     }
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->formatOutput = true;
     $root = $dom->createElement('cs:notification');
     foreach ($this->server->xmlNamespaces as $namespace => $prefix) {
         $root->setAttribute('xmlns:' . $prefix, $namespace);
     }
     $dom->appendChild($root);
     $node->getNotificationType()->serializeBody($this->server, $root);
     $this->server->httpResponse->setHeader('Content-Type', 'application/xml');
     $this->server->httpResponse->setHeader('ETag', $node->getETag());
     $this->server->httpResponse->sendStatus(200);
     $this->server->httpResponse->sendBody($dom->saveXML());
     return false;
 }
開發者ID:noble82,項目名稱:proyectos-ULS,代碼行數:40,代碼來源:Plugin.php

示例2: testIfUnmodifiedSinceInvalidDate

 /**
  */
 public function testIfUnmodifiedSinceInvalidDate()
 {
     $root = new SimpleCollection('root', array(new ServerPreconditionsNode()));
     $server = new Server($root);
     $httpRequest = HTTP\Sapi::createFromServerArray(array('HTTP_IF_UNMODIFIED_SINCE' => 'Sun, 06 Nov 1984 08:49:37 CET', 'REQUEST_URI' => '/foo'));
     $httpResponse = new HTTP\ResponseMock();
     $this->assertTrue($server->checkPreconditions($httpRequest, $httpResponse));
 }
開發者ID:mattes,項目名稱:sabre-dav,代碼行數:10,代碼來源:ServerPreconditionTest.php


注:本文中的Sabre\DAV\Server::checkPreconditions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。