ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sharee.php
Go to the documentation of this file.
1<?php
2
4
13
21class Sharee implements Element {
22
29 public $href;
30
38 public $principal;
39
46 public $properties = [];
47
63 public $access;
64
71 public $comment;
72
80
88 function __construct(array $properties = []) {
89
90 foreach ($properties as $k => $v) {
91
92 if (property_exists($this, $k)) {
93 $this->$k = $v;
94 } else {
95 throw new \InvalidArgumentException('Unknown property: ' . $k);
96 }
97
98 }
99
100 }
101
121 function xmlSerialize(Writer $writer) {
122
123
124 $writer->write([
125 new Href($this->href),
126 '{DAV:}prop' => $this->properties,
127 '{DAV:}share-access' => new ShareAccess($this->access),
128 ]);
129 switch ($this->inviteStatus) {
131 $writer->writeElement('{DAV:}invite-noresponse');
132 break;
134 $writer->writeElement('{DAV:}invite-accepted');
135 break;
137 $writer->writeElement('{DAV:}invite-declined');
138 break;
140 $writer->writeElement('{DAV:}invite-invalid');
141 break;
142 }
143
144 }
145
167 static function xmlDeserialize(Reader $reader) {
168
169 // Temporarily override configuration
170 $reader->pushContext();
171 $reader->elementMap['{DAV:}share-access'] = 'Sabre\DAV\Xml\Property\ShareAccess';
172 $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Deserializer\keyValue';
173
174 $elems = Deserializer\keyValue($reader, 'DAV:');
175
176 // Restore previous configuration
177 $reader->popContext();
178
179 $sharee = new self();
180 if (!isset($elems['href'])) {
181 throw new BadRequest('Every {DAV:}sharee must have a {DAV:}href child-element');
182 }
183 $sharee->href = $elems['href'];
184
185 if (isset($elems['prop'])) {
186 $sharee->properties = $elems['prop'];
187 }
188 if (isset($elems['comment'])) {
189 $sharee->comment = $elems['comment'];
190 }
191 if (!isset($elems['share-access'])) {
192 throw new BadRequest('Every {DAV:}sharee must have a {DAV:}share-access child element');
193 }
194 $sharee->access = $elems['share-access']->getValue();
195 return $sharee;
196
197 }
198
199}
An exception for terminatinating execution or to throw for unit testing.
This plugin implements HTTP requests and properties related to:
Definition: Plugin.php:27
This class represents the {DAV:}sharee element.
Definition: Sharee.php:21
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Sharee.php:167
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: Sharee.php:121
__construct(array $properties=[])
Creates the object.
Definition: Sharee.php:88
Href property.
Definition: Href.php:26
This class represents the {DAV:}share-access property.
Definition: ShareAccess.php:25
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
The XML Writer class.
Definition: Writer.php:31
writeElement($name, $content=null)
Write a full element tag and it's contents.
Definition: Writer.php:189
write($value)
Writes a value to the output stream.
Definition: Writer.php:98
This is the XML element interface.
Definition: Element.php:18
keyValue(Reader $reader, $namespace=null)
This class provides a number of 'deserializer' helper functions.
Definition: functions.php:61