ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
PropPatch.php
Go to the documentation of this file.
1<?php
2
4
8
20class PropPatch implements Element {
21
29 public $properties = [];
30
50 function xmlSerialize(Writer $writer) {
51
52 foreach ($this->properties as $propertyName => $propertyValue) {
53
54 if (is_null($propertyValue)) {
55 $writer->startElement("{DAV:}remove");
56 $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]);
57 $writer->endElement();
58 } else {
59 $writer->startElement("{DAV:}set");
60 $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]);
61 $writer->endElement();
62 }
63
64 }
65
66 }
67
89 static function xmlDeserialize(Reader $reader) {
90
91 $self = new self();
92
93 $elementMap = $reader->elementMap;
94 $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop';
95 $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue';
96 $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue';
97
98 $elems = $reader->parseInnerTree($elementMap);
99
100 foreach ($elems as $elem) {
101 if ($elem['name'] === '{DAV:}set') {
102 $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']);
103 }
104 if ($elem['name'] === '{DAV:}remove') {
105
106 // Ensuring there are no values.
107 foreach ($elem['value']['{DAV:}prop'] as $remove => $value) {
108 $self->properties[$remove] = null;
109 }
110
111 }
112 }
113
114 return $self;
115
116 }
117
118}
An exception for terminatinating execution or to throw for unit testing.
WebDAV PROPPATCH request parser.
Definition: PropPatch.php:20
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: PropPatch.php:50
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: PropPatch.php:89
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31
startElement($name)
Opens a new element.
Definition: Writer.php:121
write($value)
Writes a value to the output stream.
Definition: Writer.php:98
This is the XML element interface.
Definition: Element.php:18