@@ -13,35 +13,35 @@ |
||
13 | 13 | */ |
14 | 14 | class Service extends \Sabre\Xml\Service |
15 | 15 | { |
16 | - /** |
|
17 | - * This is a list of XML elements that we automatically map to PHP classes. |
|
18 | - * |
|
19 | - * For instance, this list may contain an entry `{DAV:}propfind` that would |
|
20 | - * be mapped to Sabre\DAV\Xml\Request\PropFind |
|
21 | - */ |
|
22 | - public $elementMap = [ |
|
23 | - '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus', |
|
24 | - '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', |
|
16 | + /** |
|
17 | + * This is a list of XML elements that we automatically map to PHP classes. |
|
18 | + * |
|
19 | + * For instance, this list may contain an entry `{DAV:}propfind` that would |
|
20 | + * be mapped to Sabre\DAV\Xml\Request\PropFind |
|
21 | + */ |
|
22 | + public $elementMap = [ |
|
23 | + '{DAV:}multistatus' => 'Sabre\\DAV\\Xml\\Response\\MultiStatus', |
|
24 | + '{DAV:}response' => 'Sabre\\DAV\\Xml\\Element\\Response', |
|
25 | 25 | |
26 | - // Requests |
|
27 | - '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', |
|
28 | - '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch', |
|
29 | - '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', |
|
26 | + // Requests |
|
27 | + '{DAV:}propfind' => 'Sabre\\DAV\\Xml\\Request\\PropFind', |
|
28 | + '{DAV:}propertyupdate' => 'Sabre\\DAV\\Xml\\Request\\PropPatch', |
|
29 | + '{DAV:}mkcol' => 'Sabre\\DAV\\Xml\\Request\\MkCol', |
|
30 | 30 | |
31 | - // Properties |
|
32 | - '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType', |
|
33 | - ]; |
|
31 | + // Properties |
|
32 | + '{DAV:}resourcetype' => 'Sabre\\DAV\\Xml\\Property\\ResourceType', |
|
33 | + ]; |
|
34 | 34 | |
35 | - /** |
|
36 | - * This is a default list of namespaces. |
|
37 | - * |
|
38 | - * If you are defining your own custom namespace, add it here to reduce |
|
39 | - * bandwidth and improve legibility of xml bodies. |
|
40 | - * |
|
41 | - * @var array |
|
42 | - */ |
|
43 | - public $namespaceMap = [ |
|
44 | - 'DAV:' => 'd', |
|
45 | - 'http://sabredav.org/ns' => 's', |
|
46 | - ]; |
|
35 | + /** |
|
36 | + * This is a default list of namespaces. |
|
37 | + * |
|
38 | + * If you are defining your own custom namespace, add it here to reduce |
|
39 | + * bandwidth and improve legibility of xml bodies. |
|
40 | + * |
|
41 | + * @var array |
|
42 | + */ |
|
43 | + public $namespaceMap = [ |
|
44 | + 'DAV:' => 'd', |
|
45 | + 'http://sabredav.org/ns' => 's', |
|
46 | + ]; |
|
47 | 47 | } |
@@ -22,168 +22,168 @@ |
||
22 | 22 | */ |
23 | 23 | class Sharee implements Element |
24 | 24 | { |
25 | - /** |
|
26 | - * A URL. Usually a mailto: address, could also be a principal url. |
|
27 | - * This uniquely identifies the sharee. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $href; |
|
32 | - |
|
33 | - /** |
|
34 | - * A local principal path. The server will do its best to locate the |
|
35 | - * principal uri based on the given uri. If we could find a local matching |
|
36 | - * principal uri, this property will contain the value. |
|
37 | - * |
|
38 | - * @var string|null |
|
39 | - */ |
|
40 | - public $principal; |
|
41 | - |
|
42 | - /** |
|
43 | - * A list of WebDAV properties that describe the sharee. This might for |
|
44 | - * example contain a {DAV:}displayname with the real name of the user. |
|
45 | - * |
|
46 | - * @var array |
|
47 | - */ |
|
48 | - public $properties = []; |
|
49 | - |
|
50 | - /** |
|
51 | - * Share access level. One of the Sabre\DAV\Sharing\Plugin::ACCESS |
|
52 | - * constants. |
|
53 | - * |
|
54 | - * Can be one of: |
|
55 | - * |
|
56 | - * ACCESS_READ |
|
57 | - * ACCESS_READWRITE |
|
58 | - * ACCESS_SHAREDOWNER |
|
59 | - * ACCESS_NOACCESS |
|
60 | - * |
|
61 | - * depending on context. |
|
62 | - * |
|
63 | - * @var int |
|
64 | - */ |
|
65 | - public $access; |
|
66 | - |
|
67 | - /** |
|
68 | - * When a sharee is originally invited to a share, the sharer may add |
|
69 | - * a comment. This will be placed in this property. |
|
70 | - * |
|
71 | - * @var string |
|
72 | - */ |
|
73 | - public $comment; |
|
74 | - |
|
75 | - /** |
|
76 | - * The status of the invite, should be one of the |
|
77 | - * Sabre\DAV\Sharing\Plugin::INVITE constants. |
|
78 | - * |
|
79 | - * @var int |
|
80 | - */ |
|
81 | - public $inviteStatus; |
|
82 | - |
|
83 | - /** |
|
84 | - * Creates the object. |
|
85 | - * |
|
86 | - * $properties will be used to populate all internal properties. |
|
87 | - */ |
|
88 | - public function __construct(array $properties = []) |
|
89 | - { |
|
90 | - foreach ($properties as $k => $v) { |
|
91 | - if (property_exists($this, $k)) { |
|
92 | - $this->$k = $v; |
|
93 | - } else { |
|
94 | - throw new \InvalidArgumentException('Unknown property: '.$k); |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * The xmlSerialize method is called during xml writing. |
|
101 | - * |
|
102 | - * Use the $writer argument to write its own xml serialization. |
|
103 | - * |
|
104 | - * An important note: do _not_ create a parent element. Any element |
|
105 | - * implementing XmlSerializable should only ever write what's considered |
|
106 | - * its 'inner xml'. |
|
107 | - * |
|
108 | - * The parent of the current element is responsible for writing a |
|
109 | - * containing element. |
|
110 | - * |
|
111 | - * This allows serializers to be re-used for different element names. |
|
112 | - * |
|
113 | - * If you are opening new elements, you must also close them again. |
|
114 | - */ |
|
115 | - public function xmlSerialize(Writer $writer) |
|
116 | - { |
|
117 | - $writer->write([ |
|
118 | - new Href($this->href), |
|
119 | - '{DAV:}prop' => $this->properties, |
|
120 | - '{DAV:}share-access' => new ShareAccess($this->access), |
|
121 | - ]); |
|
122 | - switch ($this->inviteStatus) { |
|
123 | - case Plugin::INVITE_NORESPONSE: |
|
124 | - $writer->writeElement('{DAV:}invite-noresponse'); |
|
125 | - break; |
|
126 | - case Plugin::INVITE_ACCEPTED: |
|
127 | - $writer->writeElement('{DAV:}invite-accepted'); |
|
128 | - break; |
|
129 | - case Plugin::INVITE_DECLINED: |
|
130 | - $writer->writeElement('{DAV:}invite-declined'); |
|
131 | - break; |
|
132 | - case Plugin::INVITE_INVALID: |
|
133 | - $writer->writeElement('{DAV:}invite-invalid'); |
|
134 | - break; |
|
135 | - } |
|
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * The deserialize method is called during xml parsing. |
|
140 | - * |
|
141 | - * This method is called statically, this is because in theory this method |
|
142 | - * may be used as a type of constructor, or factory method. |
|
143 | - * |
|
144 | - * Often you want to return an instance of the current class, but you are |
|
145 | - * free to return other data as well. |
|
146 | - * |
|
147 | - * You are responsible for advancing the reader to the next element. Not |
|
148 | - * doing anything will result in a never-ending loop. |
|
149 | - * |
|
150 | - * If you just want to skip parsing for this element altogether, you can |
|
151 | - * just call $reader->next(); |
|
152 | - * |
|
153 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
154 | - * the next element. |
|
155 | - * |
|
156 | - * @return mixed |
|
157 | - */ |
|
158 | - public static function xmlDeserialize(Reader $reader) |
|
159 | - { |
|
160 | - // Temporarily override configuration |
|
161 | - $reader->pushContext(); |
|
162 | - $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess'; |
|
163 | - $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\keyValue'; |
|
164 | - |
|
165 | - $elems = Deserializer\keyValue($reader, 'DAV:'); |
|
166 | - |
|
167 | - // Restore previous configuration |
|
168 | - $reader->popContext(); |
|
169 | - |
|
170 | - $sharee = new self(); |
|
171 | - if (!isset($elems['href'])) { |
|
172 | - throw new BadRequest('Every {DAV:}sharee must have a {DAV:}href child-element'); |
|
173 | - } |
|
174 | - $sharee->href = $elems['href']; |
|
175 | - |
|
176 | - if (isset($elems['prop'])) { |
|
177 | - $sharee->properties = $elems['prop']; |
|
178 | - } |
|
179 | - if (isset($elems['comment'])) { |
|
180 | - $sharee->comment = $elems['comment']; |
|
181 | - } |
|
182 | - if (!isset($elems['share-access'])) { |
|
183 | - throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element'); |
|
184 | - } |
|
185 | - $sharee->access = $elems['share-access']->getValue(); |
|
186 | - |
|
187 | - return $sharee; |
|
188 | - } |
|
25 | + /** |
|
26 | + * A URL. Usually a mailto: address, could also be a principal url. |
|
27 | + * This uniquely identifies the sharee. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $href; |
|
32 | + |
|
33 | + /** |
|
34 | + * A local principal path. The server will do its best to locate the |
|
35 | + * principal uri based on the given uri. If we could find a local matching |
|
36 | + * principal uri, this property will contain the value. |
|
37 | + * |
|
38 | + * @var string|null |
|
39 | + */ |
|
40 | + public $principal; |
|
41 | + |
|
42 | + /** |
|
43 | + * A list of WebDAV properties that describe the sharee. This might for |
|
44 | + * example contain a {DAV:}displayname with the real name of the user. |
|
45 | + * |
|
46 | + * @var array |
|
47 | + */ |
|
48 | + public $properties = []; |
|
49 | + |
|
50 | + /** |
|
51 | + * Share access level. One of the Sabre\DAV\Sharing\Plugin::ACCESS |
|
52 | + * constants. |
|
53 | + * |
|
54 | + * Can be one of: |
|
55 | + * |
|
56 | + * ACCESS_READ |
|
57 | + * ACCESS_READWRITE |
|
58 | + * ACCESS_SHAREDOWNER |
|
59 | + * ACCESS_NOACCESS |
|
60 | + * |
|
61 | + * depending on context. |
|
62 | + * |
|
63 | + * @var int |
|
64 | + */ |
|
65 | + public $access; |
|
66 | + |
|
67 | + /** |
|
68 | + * When a sharee is originally invited to a share, the sharer may add |
|
69 | + * a comment. This will be placed in this property. |
|
70 | + * |
|
71 | + * @var string |
|
72 | + */ |
|
73 | + public $comment; |
|
74 | + |
|
75 | + /** |
|
76 | + * The status of the invite, should be one of the |
|
77 | + * Sabre\DAV\Sharing\Plugin::INVITE constants. |
|
78 | + * |
|
79 | + * @var int |
|
80 | + */ |
|
81 | + public $inviteStatus; |
|
82 | + |
|
83 | + /** |
|
84 | + * Creates the object. |
|
85 | + * |
|
86 | + * $properties will be used to populate all internal properties. |
|
87 | + */ |
|
88 | + public function __construct(array $properties = []) |
|
89 | + { |
|
90 | + foreach ($properties as $k => $v) { |
|
91 | + if (property_exists($this, $k)) { |
|
92 | + $this->$k = $v; |
|
93 | + } else { |
|
94 | + throw new \InvalidArgumentException('Unknown property: '.$k); |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * The xmlSerialize method is called during xml writing. |
|
101 | + * |
|
102 | + * Use the $writer argument to write its own xml serialization. |
|
103 | + * |
|
104 | + * An important note: do _not_ create a parent element. Any element |
|
105 | + * implementing XmlSerializable should only ever write what's considered |
|
106 | + * its 'inner xml'. |
|
107 | + * |
|
108 | + * The parent of the current element is responsible for writing a |
|
109 | + * containing element. |
|
110 | + * |
|
111 | + * This allows serializers to be re-used for different element names. |
|
112 | + * |
|
113 | + * If you are opening new elements, you must also close them again. |
|
114 | + */ |
|
115 | + public function xmlSerialize(Writer $writer) |
|
116 | + { |
|
117 | + $writer->write([ |
|
118 | + new Href($this->href), |
|
119 | + '{DAV:}prop' => $this->properties, |
|
120 | + '{DAV:}share-access' => new ShareAccess($this->access), |
|
121 | + ]); |
|
122 | + switch ($this->inviteStatus) { |
|
123 | + case Plugin::INVITE_NORESPONSE: |
|
124 | + $writer->writeElement('{DAV:}invite-noresponse'); |
|
125 | + break; |
|
126 | + case Plugin::INVITE_ACCEPTED: |
|
127 | + $writer->writeElement('{DAV:}invite-accepted'); |
|
128 | + break; |
|
129 | + case Plugin::INVITE_DECLINED: |
|
130 | + $writer->writeElement('{DAV:}invite-declined'); |
|
131 | + break; |
|
132 | + case Plugin::INVITE_INVALID: |
|
133 | + $writer->writeElement('{DAV:}invite-invalid'); |
|
134 | + break; |
|
135 | + } |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * The deserialize method is called during xml parsing. |
|
140 | + * |
|
141 | + * This method is called statically, this is because in theory this method |
|
142 | + * may be used as a type of constructor, or factory method. |
|
143 | + * |
|
144 | + * Often you want to return an instance of the current class, but you are |
|
145 | + * free to return other data as well. |
|
146 | + * |
|
147 | + * You are responsible for advancing the reader to the next element. Not |
|
148 | + * doing anything will result in a never-ending loop. |
|
149 | + * |
|
150 | + * If you just want to skip parsing for this element altogether, you can |
|
151 | + * just call $reader->next(); |
|
152 | + * |
|
153 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
154 | + * the next element. |
|
155 | + * |
|
156 | + * @return mixed |
|
157 | + */ |
|
158 | + public static function xmlDeserialize(Reader $reader) |
|
159 | + { |
|
160 | + // Temporarily override configuration |
|
161 | + $reader->pushContext(); |
|
162 | + $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess'; |
|
163 | + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\keyValue'; |
|
164 | + |
|
165 | + $elems = Deserializer\keyValue($reader, 'DAV:'); |
|
166 | + |
|
167 | + // Restore previous configuration |
|
168 | + $reader->popContext(); |
|
169 | + |
|
170 | + $sharee = new self(); |
|
171 | + if (!isset($elems['href'])) { |
|
172 | + throw new BadRequest('Every {DAV:}sharee must have a {DAV:}href child-element'); |
|
173 | + } |
|
174 | + $sharee->href = $elems['href']; |
|
175 | + |
|
176 | + if (isset($elems['prop'])) { |
|
177 | + $sharee->properties = $elems['prop']; |
|
178 | + } |
|
179 | + if (isset($elems['comment'])) { |
|
180 | + $sharee->comment = $elems['comment']; |
|
181 | + } |
|
182 | + if (!isset($elems['share-access'])) { |
|
183 | + throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element'); |
|
184 | + } |
|
185 | + $sharee->access = $elems['share-access']->getValue(); |
|
186 | + |
|
187 | + return $sharee; |
|
188 | + } |
|
189 | 189 | } |
@@ -21,90 +21,90 @@ |
||
21 | 21 | */ |
22 | 22 | class Prop implements XmlDeserializable |
23 | 23 | { |
24 | - /** |
|
25 | - * The deserialize method is called during xml parsing. |
|
26 | - * |
|
27 | - * This method is called statically, this is because in theory this method |
|
28 | - * may be used as a type of constructor, or factory method. |
|
29 | - * |
|
30 | - * Often you want to return an instance of the current class, but you are |
|
31 | - * free to return other data as well. |
|
32 | - * |
|
33 | - * You are responsible for advancing the reader to the next element. Not |
|
34 | - * doing anything will result in a never-ending loop. |
|
35 | - * |
|
36 | - * If you just want to skip parsing for this element altogether, you can |
|
37 | - * just call $reader->next(); |
|
38 | - * |
|
39 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
40 | - * the next element. |
|
41 | - * |
|
42 | - * @return mixed |
|
43 | - */ |
|
44 | - public static function xmlDeserialize(Reader $reader) |
|
45 | - { |
|
46 | - // If there's no children, we don't do anything. |
|
47 | - if ($reader->isEmptyElement) { |
|
48 | - $reader->next(); |
|
24 | + /** |
|
25 | + * The deserialize method is called during xml parsing. |
|
26 | + * |
|
27 | + * This method is called statically, this is because in theory this method |
|
28 | + * may be used as a type of constructor, or factory method. |
|
29 | + * |
|
30 | + * Often you want to return an instance of the current class, but you are |
|
31 | + * free to return other data as well. |
|
32 | + * |
|
33 | + * You are responsible for advancing the reader to the next element. Not |
|
34 | + * doing anything will result in a never-ending loop. |
|
35 | + * |
|
36 | + * If you just want to skip parsing for this element altogether, you can |
|
37 | + * just call $reader->next(); |
|
38 | + * |
|
39 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
40 | + * the next element. |
|
41 | + * |
|
42 | + * @return mixed |
|
43 | + */ |
|
44 | + public static function xmlDeserialize(Reader $reader) |
|
45 | + { |
|
46 | + // If there's no children, we don't do anything. |
|
47 | + if ($reader->isEmptyElement) { |
|
48 | + $reader->next(); |
|
49 | 49 | |
50 | - return []; |
|
51 | - } |
|
50 | + return []; |
|
51 | + } |
|
52 | 52 | |
53 | - $values = []; |
|
53 | + $values = []; |
|
54 | 54 | |
55 | - $reader->read(); |
|
56 | - do { |
|
57 | - if (Reader::ELEMENT === $reader->nodeType) { |
|
58 | - $clark = $reader->getClark(); |
|
59 | - $values[$clark] = self::parseCurrentElement($reader)['value']; |
|
60 | - } else { |
|
61 | - $reader->read(); |
|
62 | - } |
|
63 | - } while (Reader::END_ELEMENT !== $reader->nodeType); |
|
55 | + $reader->read(); |
|
56 | + do { |
|
57 | + if (Reader::ELEMENT === $reader->nodeType) { |
|
58 | + $clark = $reader->getClark(); |
|
59 | + $values[$clark] = self::parseCurrentElement($reader)['value']; |
|
60 | + } else { |
|
61 | + $reader->read(); |
|
62 | + } |
|
63 | + } while (Reader::END_ELEMENT !== $reader->nodeType); |
|
64 | 64 | |
65 | - $reader->read(); |
|
65 | + $reader->read(); |
|
66 | 66 | |
67 | - return $values; |
|
68 | - } |
|
67 | + return $values; |
|
68 | + } |
|
69 | 69 | |
70 | - /** |
|
71 | - * This function behaves similar to Sabre\Xml\Reader::parseCurrentElement, |
|
72 | - * but instead of creating deep xml array structures, it will turn any |
|
73 | - * top-level element it doesn't recognize into either a string, or an |
|
74 | - * XmlFragment class. |
|
75 | - * |
|
76 | - * This method returns arn array with 2 properties: |
|
77 | - * * name - A clark-notation XML element name. |
|
78 | - * * value - The parsed value. |
|
79 | - * |
|
80 | - * @return array |
|
81 | - */ |
|
82 | - private static function parseCurrentElement(Reader $reader) |
|
83 | - { |
|
84 | - $name = $reader->getClark(); |
|
70 | + /** |
|
71 | + * This function behaves similar to Sabre\Xml\Reader::parseCurrentElement, |
|
72 | + * but instead of creating deep xml array structures, it will turn any |
|
73 | + * top-level element it doesn't recognize into either a string, or an |
|
74 | + * XmlFragment class. |
|
75 | + * |
|
76 | + * This method returns arn array with 2 properties: |
|
77 | + * * name - A clark-notation XML element name. |
|
78 | + * * value - The parsed value. |
|
79 | + * |
|
80 | + * @return array |
|
81 | + */ |
|
82 | + private static function parseCurrentElement(Reader $reader) |
|
83 | + { |
|
84 | + $name = $reader->getClark(); |
|
85 | 85 | |
86 | - if (array_key_exists($name, $reader->elementMap)) { |
|
87 | - $deserializer = $reader->elementMap[$name]; |
|
88 | - if (is_subclass_of($deserializer, 'Sabre\\Xml\\XmlDeserializable')) { |
|
89 | - $value = call_user_func([$deserializer, 'xmlDeserialize'], $reader); |
|
90 | - } elseif (is_callable($deserializer)) { |
|
91 | - $value = call_user_func($deserializer, $reader); |
|
92 | - } else { |
|
93 | - $type = gettype($deserializer); |
|
94 | - if ('string' === $type) { |
|
95 | - $type .= ' ('.$deserializer.')'; |
|
96 | - } elseif ('object' === $type) { |
|
97 | - $type .= ' ('.get_class($deserializer).')'; |
|
98 | - } |
|
99 | - throw new \LogicException('Could not use this type as a deserializer: '.$type); |
|
100 | - } |
|
101 | - } else { |
|
102 | - $value = Complex::xmlDeserialize($reader); |
|
103 | - } |
|
86 | + if (array_key_exists($name, $reader->elementMap)) { |
|
87 | + $deserializer = $reader->elementMap[$name]; |
|
88 | + if (is_subclass_of($deserializer, 'Sabre\\Xml\\XmlDeserializable')) { |
|
89 | + $value = call_user_func([$deserializer, 'xmlDeserialize'], $reader); |
|
90 | + } elseif (is_callable($deserializer)) { |
|
91 | + $value = call_user_func($deserializer, $reader); |
|
92 | + } else { |
|
93 | + $type = gettype($deserializer); |
|
94 | + if ('string' === $type) { |
|
95 | + $type .= ' ('.$deserializer.')'; |
|
96 | + } elseif ('object' === $type) { |
|
97 | + $type .= ' ('.get_class($deserializer).')'; |
|
98 | + } |
|
99 | + throw new \LogicException('Could not use this type as a deserializer: '.$type); |
|
100 | + } |
|
101 | + } else { |
|
102 | + $value = Complex::xmlDeserialize($reader); |
|
103 | + } |
|
104 | 104 | |
105 | - return [ |
|
106 | - 'name' => $name, |
|
107 | - 'value' => $value, |
|
108 | - ]; |
|
109 | - } |
|
105 | + return [ |
|
106 | + 'name' => $name, |
|
107 | + 'value' => $value, |
|
108 | + ]; |
|
109 | + } |
|
110 | 110 | } |
@@ -22,63 +22,63 @@ |
||
22 | 22 | */ |
23 | 23 | class Lock implements XmlDeserializable |
24 | 24 | { |
25 | - /** |
|
26 | - * Owner of the lock. |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - public $owner; |
|
25 | + /** |
|
26 | + * Owner of the lock. |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + public $owner; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Scope of the lock. |
|
34 | - * |
|
35 | - * Either LockInfo::SHARED or LockInfo::EXCLUSIVE |
|
36 | - * |
|
37 | - * @var int |
|
38 | - */ |
|
39 | - public $scope; |
|
32 | + /** |
|
33 | + * Scope of the lock. |
|
34 | + * |
|
35 | + * Either LockInfo::SHARED or LockInfo::EXCLUSIVE |
|
36 | + * |
|
37 | + * @var int |
|
38 | + */ |
|
39 | + public $scope; |
|
40 | 40 | |
41 | - /** |
|
42 | - * The deserialize method is called during xml parsing. |
|
43 | - * |
|
44 | - * This method is called statically, this is because in theory this method |
|
45 | - * may be used as a type of constructor, or factory method. |
|
46 | - * |
|
47 | - * Often you want to return an instance of the current class, but you are |
|
48 | - * free to return other data as well. |
|
49 | - * |
|
50 | - * You are responsible for advancing the reader to the next element. Not |
|
51 | - * doing anything will result in a never-ending loop. |
|
52 | - * |
|
53 | - * If you just want to skip parsing for this element altogether, you can |
|
54 | - * just call $reader->next(); |
|
55 | - * |
|
56 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | - * the next element. |
|
58 | - * |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public static function xmlDeserialize(Reader $reader) |
|
62 | - { |
|
63 | - $reader->pushContext(); |
|
64 | - $reader->elementMap['{DAV:}owner'] = 'Sabre\\Xml\\Element\\XmlFragment'; |
|
41 | + /** |
|
42 | + * The deserialize method is called during xml parsing. |
|
43 | + * |
|
44 | + * This method is called statically, this is because in theory this method |
|
45 | + * may be used as a type of constructor, or factory method. |
|
46 | + * |
|
47 | + * Often you want to return an instance of the current class, but you are |
|
48 | + * free to return other data as well. |
|
49 | + * |
|
50 | + * You are responsible for advancing the reader to the next element. Not |
|
51 | + * doing anything will result in a never-ending loop. |
|
52 | + * |
|
53 | + * If you just want to skip parsing for this element altogether, you can |
|
54 | + * just call $reader->next(); |
|
55 | + * |
|
56 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | + * the next element. |
|
58 | + * |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public static function xmlDeserialize(Reader $reader) |
|
62 | + { |
|
63 | + $reader->pushContext(); |
|
64 | + $reader->elementMap['{DAV:}owner'] = 'Sabre\\Xml\\Element\\XmlFragment'; |
|
65 | 65 | |
66 | - $values = KeyValue::xmlDeserialize($reader); |
|
66 | + $values = KeyValue::xmlDeserialize($reader); |
|
67 | 67 | |
68 | - $reader->popContext(); |
|
68 | + $reader->popContext(); |
|
69 | 69 | |
70 | - $new = new self(); |
|
71 | - $new->owner = !empty($values['{DAV:}owner']) ? $values['{DAV:}owner']->getXml() : null; |
|
72 | - $new->scope = LockInfo::SHARED; |
|
70 | + $new = new self(); |
|
71 | + $new->owner = !empty($values['{DAV:}owner']) ? $values['{DAV:}owner']->getXml() : null; |
|
72 | + $new->scope = LockInfo::SHARED; |
|
73 | 73 | |
74 | - if (isset($values['{DAV:}lockscope'])) { |
|
75 | - foreach ($values['{DAV:}lockscope'] as $elem) { |
|
76 | - if ('{DAV:}exclusive' === $elem['name']) { |
|
77 | - $new->scope = LockInfo::EXCLUSIVE; |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
74 | + if (isset($values['{DAV:}lockscope'])) { |
|
75 | + foreach ($values['{DAV:}lockscope'] as $elem) { |
|
76 | + if ('{DAV:}exclusive' === $elem['name']) { |
|
77 | + $new->scope = LockInfo::EXCLUSIVE; |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - return $new; |
|
83 | - } |
|
82 | + return $new; |
|
83 | + } |
|
84 | 84 | } |
@@ -21,89 +21,89 @@ |
||
21 | 21 | */ |
22 | 22 | class PropPatch implements Element |
23 | 23 | { |
24 | - /** |
|
25 | - * The list of properties that will be updated and removed. |
|
26 | - * |
|
27 | - * If a property will be removed, it's value will be set to null. |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - public $properties = []; |
|
24 | + /** |
|
25 | + * The list of properties that will be updated and removed. |
|
26 | + * |
|
27 | + * If a property will be removed, it's value will be set to null. |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + public $properties = []; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The xmlSerialize method is called during xml writing. |
|
35 | - * |
|
36 | - * Use the $writer argument to write its own xml serialization. |
|
37 | - * |
|
38 | - * An important note: do _not_ create a parent element. Any element |
|
39 | - * implementing XmlSerializable should only ever write what's considered |
|
40 | - * its 'inner xml'. |
|
41 | - * |
|
42 | - * The parent of the current element is responsible for writing a |
|
43 | - * containing element. |
|
44 | - * |
|
45 | - * This allows serializers to be re-used for different element names. |
|
46 | - * |
|
47 | - * If you are opening new elements, you must also close them again. |
|
48 | - */ |
|
49 | - public function xmlSerialize(Writer $writer) |
|
50 | - { |
|
51 | - foreach ($this->properties as $propertyName => $propertyValue) { |
|
52 | - if (is_null($propertyValue)) { |
|
53 | - $writer->startElement('{DAV:}remove'); |
|
54 | - $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
55 | - $writer->endElement(); |
|
56 | - } else { |
|
57 | - $writer->startElement('{DAV:}set'); |
|
58 | - $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
59 | - $writer->endElement(); |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
33 | + /** |
|
34 | + * The xmlSerialize method is called during xml writing. |
|
35 | + * |
|
36 | + * Use the $writer argument to write its own xml serialization. |
|
37 | + * |
|
38 | + * An important note: do _not_ create a parent element. Any element |
|
39 | + * implementing XmlSerializable should only ever write what's considered |
|
40 | + * its 'inner xml'. |
|
41 | + * |
|
42 | + * The parent of the current element is responsible for writing a |
|
43 | + * containing element. |
|
44 | + * |
|
45 | + * This allows serializers to be re-used for different element names. |
|
46 | + * |
|
47 | + * If you are opening new elements, you must also close them again. |
|
48 | + */ |
|
49 | + public function xmlSerialize(Writer $writer) |
|
50 | + { |
|
51 | + foreach ($this->properties as $propertyName => $propertyValue) { |
|
52 | + if (is_null($propertyValue)) { |
|
53 | + $writer->startElement('{DAV:}remove'); |
|
54 | + $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
55 | + $writer->endElement(); |
|
56 | + } else { |
|
57 | + $writer->startElement('{DAV:}set'); |
|
58 | + $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
59 | + $writer->endElement(); |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * The deserialize method is called during xml parsing. |
|
66 | - * |
|
67 | - * This method is called statically, this is because in theory this method |
|
68 | - * may be used as a type of constructor, or factory method. |
|
69 | - * |
|
70 | - * Often you want to return an instance of the current class, but you are |
|
71 | - * free to return other data as well. |
|
72 | - * |
|
73 | - * You are responsible for advancing the reader to the next element. Not |
|
74 | - * doing anything will result in a never-ending loop. |
|
75 | - * |
|
76 | - * If you just want to skip parsing for this element altogether, you can |
|
77 | - * just call $reader->next(); |
|
78 | - * |
|
79 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | - * the next element. |
|
81 | - * |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - public static function xmlDeserialize(Reader $reader) |
|
85 | - { |
|
86 | - $self = new self(); |
|
64 | + /** |
|
65 | + * The deserialize method is called during xml parsing. |
|
66 | + * |
|
67 | + * This method is called statically, this is because in theory this method |
|
68 | + * may be used as a type of constructor, or factory method. |
|
69 | + * |
|
70 | + * Often you want to return an instance of the current class, but you are |
|
71 | + * free to return other data as well. |
|
72 | + * |
|
73 | + * You are responsible for advancing the reader to the next element. Not |
|
74 | + * doing anything will result in a never-ending loop. |
|
75 | + * |
|
76 | + * If you just want to skip parsing for this element altogether, you can |
|
77 | + * just call $reader->next(); |
|
78 | + * |
|
79 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | + * the next element. |
|
81 | + * |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + public static function xmlDeserialize(Reader $reader) |
|
85 | + { |
|
86 | + $self = new self(); |
|
87 | 87 | |
88 | - $elementMap = $reader->elementMap; |
|
89 | - $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
90 | - $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
91 | - $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
88 | + $elementMap = $reader->elementMap; |
|
89 | + $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
90 | + $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
91 | + $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
92 | 92 | |
93 | - $elems = $reader->parseInnerTree($elementMap); |
|
93 | + $elems = $reader->parseInnerTree($elementMap); |
|
94 | 94 | |
95 | - foreach ($elems as $elem) { |
|
96 | - if ('{DAV:}set' === $elem['name']) { |
|
97 | - $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
98 | - } |
|
99 | - if ('{DAV:}remove' === $elem['name']) { |
|
100 | - // Ensuring there are no values. |
|
101 | - foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { |
|
102 | - $self->properties[$remove] = null; |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
95 | + foreach ($elems as $elem) { |
|
96 | + if ('{DAV:}set' === $elem['name']) { |
|
97 | + $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
98 | + } |
|
99 | + if ('{DAV:}remove' === $elem['name']) { |
|
100 | + // Ensuring there are no values. |
|
101 | + foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { |
|
102 | + $self->properties[$remove] = null; |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | 106 | |
107 | - return $self; |
|
108 | - } |
|
107 | + return $self; |
|
108 | + } |
|
109 | 109 | } |
@@ -20,61 +20,61 @@ |
||
20 | 20 | */ |
21 | 21 | class MkCol implements XmlDeserializable |
22 | 22 | { |
23 | - /** |
|
24 | - * The list of properties that will be set. |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - protected $properties = []; |
|
23 | + /** |
|
24 | + * The list of properties that will be set. |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + protected $properties = []; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Returns a key=>value array with properties that are supposed to get set |
|
32 | - * during creation of the new collection. |
|
33 | - * |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function getProperties() |
|
37 | - { |
|
38 | - return $this->properties; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Returns a key=>value array with properties that are supposed to get set |
|
32 | + * during creation of the new collection. |
|
33 | + * |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function getProperties() |
|
37 | + { |
|
38 | + return $this->properties; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * The deserialize method is called during xml parsing. |
|
43 | - * |
|
44 | - * This method is called statically, this is because in theory this method |
|
45 | - * may be used as a type of constructor, or factory method. |
|
46 | - * |
|
47 | - * Often you want to return an instance of the current class, but you are |
|
48 | - * free to return other data as well. |
|
49 | - * |
|
50 | - * You are responsible for advancing the reader to the next element. Not |
|
51 | - * doing anything will result in a never-ending loop. |
|
52 | - * |
|
53 | - * If you just want to skip parsing for this element altogether, you can |
|
54 | - * just call $reader->next(); |
|
55 | - * |
|
56 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | - * the next element. |
|
58 | - * |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public static function xmlDeserialize(Reader $reader) |
|
62 | - { |
|
63 | - $self = new self(); |
|
41 | + /** |
|
42 | + * The deserialize method is called during xml parsing. |
|
43 | + * |
|
44 | + * This method is called statically, this is because in theory this method |
|
45 | + * may be used as a type of constructor, or factory method. |
|
46 | + * |
|
47 | + * Often you want to return an instance of the current class, but you are |
|
48 | + * free to return other data as well. |
|
49 | + * |
|
50 | + * You are responsible for advancing the reader to the next element. Not |
|
51 | + * doing anything will result in a never-ending loop. |
|
52 | + * |
|
53 | + * If you just want to skip parsing for this element altogether, you can |
|
54 | + * just call $reader->next(); |
|
55 | + * |
|
56 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | + * the next element. |
|
58 | + * |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public static function xmlDeserialize(Reader $reader) |
|
62 | + { |
|
63 | + $self = new self(); |
|
64 | 64 | |
65 | - $elementMap = $reader->elementMap; |
|
66 | - $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
67 | - $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
68 | - $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
65 | + $elementMap = $reader->elementMap; |
|
66 | + $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
67 | + $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
68 | + $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
69 | 69 | |
70 | - $elems = $reader->parseInnerTree($elementMap); |
|
70 | + $elems = $reader->parseInnerTree($elementMap); |
|
71 | 71 | |
72 | - foreach ($elems as $elem) { |
|
73 | - if ('{DAV:}set' === $elem['name']) { |
|
74 | - $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
75 | - } |
|
76 | - } |
|
72 | + foreach ($elems as $elem) { |
|
73 | + if ('{DAV:}set' === $elem['name']) { |
|
74 | + $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - return $self; |
|
79 | - } |
|
78 | + return $self; |
|
79 | + } |
|
80 | 80 | } |
@@ -21,60 +21,60 @@ |
||
21 | 21 | */ |
22 | 22 | class ShareResource implements XmlDeserializable |
23 | 23 | { |
24 | - /** |
|
25 | - * The list of new people added or updated or removed from the share. |
|
26 | - * |
|
27 | - * @var Sharee[] |
|
28 | - */ |
|
29 | - public $sharees = []; |
|
24 | + /** |
|
25 | + * The list of new people added or updated or removed from the share. |
|
26 | + * |
|
27 | + * @var Sharee[] |
|
28 | + */ |
|
29 | + public $sharees = []; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor. |
|
33 | - * |
|
34 | - * @param Sharee[] $sharees |
|
35 | - */ |
|
36 | - public function __construct(array $sharees) |
|
37 | - { |
|
38 | - $this->sharees = $sharees; |
|
39 | - } |
|
31 | + /** |
|
32 | + * Constructor. |
|
33 | + * |
|
34 | + * @param Sharee[] $sharees |
|
35 | + */ |
|
36 | + public function __construct(array $sharees) |
|
37 | + { |
|
38 | + $this->sharees = $sharees; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * The deserialize method is called during xml parsing. |
|
43 | - * |
|
44 | - * This method is called statically, this is because in theory this method |
|
45 | - * may be used as a type of constructor, or factory method. |
|
46 | - * |
|
47 | - * Often you want to return an instance of the current class, but you are |
|
48 | - * free to return other data as well. |
|
49 | - * |
|
50 | - * You are responsible for advancing the reader to the next element. Not |
|
51 | - * doing anything will result in a never-ending loop. |
|
52 | - * |
|
53 | - * If you just want to skip parsing for this element altogether, you can |
|
54 | - * just call $reader->next(); |
|
55 | - * |
|
56 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | - * the next element. |
|
58 | - * |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public static function xmlDeserialize(Reader $reader) |
|
62 | - { |
|
63 | - $elems = $reader->parseInnerTree([ |
|
64 | - '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', |
|
65 | - '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', |
|
66 | - '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', |
|
67 | - ]); |
|
41 | + /** |
|
42 | + * The deserialize method is called during xml parsing. |
|
43 | + * |
|
44 | + * This method is called statically, this is because in theory this method |
|
45 | + * may be used as a type of constructor, or factory method. |
|
46 | + * |
|
47 | + * Often you want to return an instance of the current class, but you are |
|
48 | + * free to return other data as well. |
|
49 | + * |
|
50 | + * You are responsible for advancing the reader to the next element. Not |
|
51 | + * doing anything will result in a never-ending loop. |
|
52 | + * |
|
53 | + * If you just want to skip parsing for this element altogether, you can |
|
54 | + * just call $reader->next(); |
|
55 | + * |
|
56 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | + * the next element. |
|
58 | + * |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public static function xmlDeserialize(Reader $reader) |
|
62 | + { |
|
63 | + $elems = $reader->parseInnerTree([ |
|
64 | + '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', |
|
65 | + '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', |
|
66 | + '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', |
|
67 | + ]); |
|
68 | 68 | |
69 | - $sharees = []; |
|
69 | + $sharees = []; |
|
70 | 70 | |
71 | - foreach ($elems as $elem) { |
|
72 | - if ('{DAV:}sharee' !== $elem['name']) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $sharees[] = $elem['value']; |
|
76 | - } |
|
71 | + foreach ($elems as $elem) { |
|
72 | + if ('{DAV:}sharee' !== $elem['name']) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $sharees[] = $elem['value']; |
|
76 | + } |
|
77 | 77 | |
78 | - return new self($sharees); |
|
79 | - } |
|
78 | + return new self($sharees); |
|
79 | + } |
|
80 | 80 | } |
@@ -22,97 +22,97 @@ |
||
22 | 22 | */ |
23 | 23 | class SyncCollectionReport implements XmlDeserializable |
24 | 24 | { |
25 | - /** |
|
26 | - * The sync-token the client supplied for the report. |
|
27 | - * |
|
28 | - * @var string|null |
|
29 | - */ |
|
30 | - public $syncToken; |
|
31 | - |
|
32 | - /** |
|
33 | - * The 'depth' of the sync the client is interested in. |
|
34 | - * |
|
35 | - * @var int |
|
36 | - */ |
|
37 | - public $syncLevel; |
|
38 | - |
|
39 | - /** |
|
40 | - * Maximum amount of items returned. |
|
41 | - * |
|
42 | - * @var int|null |
|
43 | - */ |
|
44 | - public $limit; |
|
45 | - |
|
46 | - /** |
|
47 | - * The list of properties that are being requested for every change. |
|
48 | - * |
|
49 | - * @var array|null |
|
50 | - */ |
|
51 | - public $properties; |
|
52 | - |
|
53 | - /** |
|
54 | - * The deserialize method is called during xml parsing. |
|
55 | - * |
|
56 | - * This method is called statically, this is because in theory this method |
|
57 | - * may be used as a type of constructor, or factory method. |
|
58 | - * |
|
59 | - * Often you want to return an instance of the current class, but you are |
|
60 | - * free to return other data as well. |
|
61 | - * |
|
62 | - * You are responsible for advancing the reader to the next element. Not |
|
63 | - * doing anything will result in a never-ending loop. |
|
64 | - * |
|
65 | - * If you just want to skip parsing for this element altogether, you can |
|
66 | - * just call $reader->next(); |
|
67 | - * |
|
68 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
69 | - * the next element. |
|
70 | - * |
|
71 | - * @return mixed |
|
72 | - */ |
|
73 | - public static function xmlDeserialize(Reader $reader) |
|
74 | - { |
|
75 | - $self = new self(); |
|
76 | - |
|
77 | - $reader->pushContext(); |
|
78 | - |
|
79 | - $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
80 | - $elems = KeyValue::xmlDeserialize($reader); |
|
81 | - |
|
82 | - $reader->popContext(); |
|
83 | - |
|
84 | - $required = [ |
|
85 | - '{DAV:}sync-token', |
|
86 | - '{DAV:}prop', |
|
87 | - ]; |
|
88 | - |
|
89 | - foreach ($required as $elem) { |
|
90 | - if (!array_key_exists($elem, $elems)) { |
|
91 | - throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - $self->properties = $elems['{DAV:}prop']; |
|
96 | - $self->syncToken = $elems['{DAV:}sync-token']; |
|
97 | - |
|
98 | - if (isset($elems['{DAV:}limit'])) { |
|
99 | - $nresults = null; |
|
100 | - foreach ($elems['{DAV:}limit'] as $child) { |
|
101 | - if ('{DAV:}nresults' === $child['name']) { |
|
102 | - $nresults = (int) $child['value']; |
|
103 | - } |
|
104 | - } |
|
105 | - $self->limit = $nresults; |
|
106 | - } |
|
107 | - |
|
108 | - if (isset($elems['{DAV:}sync-level'])) { |
|
109 | - $value = $elems['{DAV:}sync-level']; |
|
110 | - if ('infinity' === $value) { |
|
111 | - $value = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
112 | - } |
|
113 | - $self->syncLevel = $value; |
|
114 | - } |
|
115 | - |
|
116 | - return $self; |
|
117 | - } |
|
25 | + /** |
|
26 | + * The sync-token the client supplied for the report. |
|
27 | + * |
|
28 | + * @var string|null |
|
29 | + */ |
|
30 | + public $syncToken; |
|
31 | + |
|
32 | + /** |
|
33 | + * The 'depth' of the sync the client is interested in. |
|
34 | + * |
|
35 | + * @var int |
|
36 | + */ |
|
37 | + public $syncLevel; |
|
38 | + |
|
39 | + /** |
|
40 | + * Maximum amount of items returned. |
|
41 | + * |
|
42 | + * @var int|null |
|
43 | + */ |
|
44 | + public $limit; |
|
45 | + |
|
46 | + /** |
|
47 | + * The list of properties that are being requested for every change. |
|
48 | + * |
|
49 | + * @var array|null |
|
50 | + */ |
|
51 | + public $properties; |
|
52 | + |
|
53 | + /** |
|
54 | + * The deserialize method is called during xml parsing. |
|
55 | + * |
|
56 | + * This method is called statically, this is because in theory this method |
|
57 | + * may be used as a type of constructor, or factory method. |
|
58 | + * |
|
59 | + * Often you want to return an instance of the current class, but you are |
|
60 | + * free to return other data as well. |
|
61 | + * |
|
62 | + * You are responsible for advancing the reader to the next element. Not |
|
63 | + * doing anything will result in a never-ending loop. |
|
64 | + * |
|
65 | + * If you just want to skip parsing for this element altogether, you can |
|
66 | + * just call $reader->next(); |
|
67 | + * |
|
68 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
69 | + * the next element. |
|
70 | + * |
|
71 | + * @return mixed |
|
72 | + */ |
|
73 | + public static function xmlDeserialize(Reader $reader) |
|
74 | + { |
|
75 | + $self = new self(); |
|
76 | + |
|
77 | + $reader->pushContext(); |
|
78 | + |
|
79 | + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
80 | + $elems = KeyValue::xmlDeserialize($reader); |
|
81 | + |
|
82 | + $reader->popContext(); |
|
83 | + |
|
84 | + $required = [ |
|
85 | + '{DAV:}sync-token', |
|
86 | + '{DAV:}prop', |
|
87 | + ]; |
|
88 | + |
|
89 | + foreach ($required as $elem) { |
|
90 | + if (!array_key_exists($elem, $elems)) { |
|
91 | + throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + $self->properties = $elems['{DAV:}prop']; |
|
96 | + $self->syncToken = $elems['{DAV:}sync-token']; |
|
97 | + |
|
98 | + if (isset($elems['{DAV:}limit'])) { |
|
99 | + $nresults = null; |
|
100 | + foreach ($elems['{DAV:}limit'] as $child) { |
|
101 | + if ('{DAV:}nresults' === $child['name']) { |
|
102 | + $nresults = (int) $child['value']; |
|
103 | + } |
|
104 | + } |
|
105 | + $self->limit = $nresults; |
|
106 | + } |
|
107 | + |
|
108 | + if (isset($elems['{DAV:}sync-level'])) { |
|
109 | + $value = $elems['{DAV:}sync-level']; |
|
110 | + if ('infinity' === $value) { |
|
111 | + $value = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
112 | + } |
|
113 | + $self->syncLevel = $value; |
|
114 | + } |
|
115 | + |
|
116 | + return $self; |
|
117 | + } |
|
118 | 118 | } |
@@ -21,59 +21,59 @@ |
||
21 | 21 | */ |
22 | 22 | class PropFind implements XmlDeserializable |
23 | 23 | { |
24 | - /** |
|
25 | - * If this is set to true, this was an 'allprop' request. |
|
26 | - * |
|
27 | - * @var bool |
|
28 | - */ |
|
29 | - public $allProp = false; |
|
24 | + /** |
|
25 | + * If this is set to true, this was an 'allprop' request. |
|
26 | + * |
|
27 | + * @var bool |
|
28 | + */ |
|
29 | + public $allProp = false; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The property list. |
|
33 | - * |
|
34 | - * @var array|null |
|
35 | - */ |
|
36 | - public $properties; |
|
31 | + /** |
|
32 | + * The property list. |
|
33 | + * |
|
34 | + * @var array|null |
|
35 | + */ |
|
36 | + public $properties; |
|
37 | 37 | |
38 | - /** |
|
39 | - * The deserialize method is called during xml parsing. |
|
40 | - * |
|
41 | - * This method is called statically, this is because in theory this method |
|
42 | - * may be used as a type of constructor, or factory method. |
|
43 | - * |
|
44 | - * Often you want to return an instance of the current class, but you are |
|
45 | - * free to return other data as well. |
|
46 | - * |
|
47 | - * You are responsible for advancing the reader to the next element. Not |
|
48 | - * doing anything will result in a never-ending loop. |
|
49 | - * |
|
50 | - * If you just want to skip parsing for this element altogether, you can |
|
51 | - * just call $reader->next(); |
|
52 | - * |
|
53 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
54 | - * the next element. |
|
55 | - * |
|
56 | - * @return mixed |
|
57 | - */ |
|
58 | - public static function xmlDeserialize(Reader $reader) |
|
59 | - { |
|
60 | - $self = new self(); |
|
38 | + /** |
|
39 | + * The deserialize method is called during xml parsing. |
|
40 | + * |
|
41 | + * This method is called statically, this is because in theory this method |
|
42 | + * may be used as a type of constructor, or factory method. |
|
43 | + * |
|
44 | + * Often you want to return an instance of the current class, but you are |
|
45 | + * free to return other data as well. |
|
46 | + * |
|
47 | + * You are responsible for advancing the reader to the next element. Not |
|
48 | + * doing anything will result in a never-ending loop. |
|
49 | + * |
|
50 | + * If you just want to skip parsing for this element altogether, you can |
|
51 | + * just call $reader->next(); |
|
52 | + * |
|
53 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
54 | + * the next element. |
|
55 | + * |
|
56 | + * @return mixed |
|
57 | + */ |
|
58 | + public static function xmlDeserialize(Reader $reader) |
|
59 | + { |
|
60 | + $self = new self(); |
|
61 | 61 | |
62 | - $reader->pushContext(); |
|
63 | - $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
62 | + $reader->pushContext(); |
|
63 | + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
64 | 64 | |
65 | - foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { |
|
66 | - switch ($k) { |
|
67 | - case '{DAV:}prop': |
|
68 | - $self->properties = $v; |
|
69 | - break; |
|
70 | - case '{DAV:}allprop': |
|
71 | - $self->allProp = true; |
|
72 | - } |
|
73 | - } |
|
65 | + foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { |
|
66 | + switch ($k) { |
|
67 | + case '{DAV:}prop': |
|
68 | + $self->properties = $v; |
|
69 | + break; |
|
70 | + case '{DAV:}allprop': |
|
71 | + $self->allProp = true; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - $reader->popContext(); |
|
75 | + $reader->popContext(); |
|
76 | 76 | |
77 | - return $self; |
|
78 | - } |
|
77 | + return $self; |
|
78 | + } |
|
79 | 79 | } |