ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sharee.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV\Xml\Element;
4 
13 
21 class Sharee implements Element {
22 
29  public $href;
30 
38  public $principal;
39 
46  public $properties = [];
47 
63  public $access;
64 
71  public $comment;
72 
79  public $inviteStatus;
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 }
This class represents the {DAV:}sharee element.
Definition: Sharee.php:21
keyValue(Reader $reader, $namespace=null)
This class provides a number of &#39;deserializer&#39; helper functions.
Definition: functions.php:61
Href property.
Definition: Href.php:26
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
__construct(array $properties=[])
Creates the object.
Definition: Sharee.php:88
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
Definition: Sharee.php:167
This is the XML element interface.
Definition: Element.php:18
write($value)
Writes a value to the output stream.
Definition: Writer.php:98
This class represents the {DAV:}share-access property.
Definition: ShareAccess.php:25
writeElement($name, $content=null)
Write a full element tag and it&#39;s contents.
Definition: Writer.php:189
The XML Writer class.
Definition: Writer.php:31
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Definition: Sharee.php:121