本文整理匯總了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));
}