本文整理汇总了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;
}
示例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));
}