]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/lib/Sabre/DAV/Exception/PreconditionFailed.php
Merge remote branch 'friendica/master'
[friendica-addons.git] / dav / SabreDAV / lib / Sabre / DAV / Exception / PreconditionFailed.php
1 <?php
2
3 /**
4  * PreconditionFailed
5  *
6  * This exception is normally thrown when a client submitted a conditional request,
7  * like for example an If, If-None-Match or If-Match header, which caused the HTTP
8  * request to not execute (the condition of the header failed)
9  *
10  * @package Sabre
11  * @subpackage DAV
12  * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
13  * @author Evert Pot (http://www.rooftopsolutions.nl/) 
14  * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
15  */
16 class Sabre_DAV_Exception_PreconditionFailed extends Sabre_DAV_Exception {
17
18     /**
19      * When this exception is thrown, the header-name might be set.
20      *
21      * This allows the exception-catching code to determine which HTTP header
22      * caused the exception.
23      *
24      * @var string
25      */
26     public $header = null;
27
28     /**
29      * Create the exception
30      *
31      * @param string $message
32      * @param string $header
33      */
34     public function __construct($message, $header=null) {
35
36         parent::__construct($message);
37         $this->header = $header;
38
39     }
40
41     /**
42      * Returns the HTTP statuscode for this exception
43      *
44      * @return int
45      */
46     public function getHTTPCode() {
47
48         return 412;
49
50     }
51
52     /**
53      * This method allows the exception to include additional information into the WebDAV error response
54      *
55      * @param Sabre_DAV_Server $server
56      * @param DOMElement $errorNode
57      * @return void
58      */
59     public function serialize(Sabre_DAV_Server $server,DOMElement $errorNode) {
60
61         if ($this->header) {
62             $prop = $errorNode->ownerDocument->createElement('s:header');
63             $prop->nodeValue = $this->header;
64             $errorNode->appendChild($prop);
65         }
66
67     }
68
69 }