ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
MultiStatus.php
Go to the documentation of this file.
1 <?php
2 
4 
8 
22 class MultiStatus implements Element {
23 
29  protected $responses;
30 
36  protected $syncToken;
37 
44  function __construct(array $responses, $syncToken = null) {
45 
46  $this->responses = $responses;
47  $this->syncToken = $syncToken;
48 
49  }
50 
56  function getResponses() {
57 
58  return $this->responses;
59 
60  }
61 
67  function getSyncToken() {
68 
69  return $this->syncToken;
70 
71  }
72 
88  function xmlSerialize(Writer $writer) {
89 
90  foreach ($this->getResponses() as $response) {
91  $writer->writeElement('{DAV:}response', $response);
92  }
93  if ($syncToken = $this->getSyncToken()) {
94  $writer->writeElement('{DAV:}sync-token', $syncToken);
95  }
96 
97  }
98 
120  static function xmlDeserialize(Reader $reader) {
121 
122  $elementMap = $reader->elementMap;
123  $elementMap['{DAV:}prop'] = 'Sabre\\DAV\\Xml\\Element\\Prop';
124  $elements = $reader->parseInnerTree($elementMap);
125 
126  $responses = [];
127  $syncToken = null;
128 
129  if ($elements) foreach ($elements as $elem) {
130  if ($elem['name'] === '{DAV:}response') {
131  $responses[] = $elem['value'];
132  }
133  if ($elem['name'] === '{DAV:}sync-token') {
134  $syncToken = $elem['value'];
135  }
136  }
137 
138  return new self($responses, $syncToken);
139 
140  }
141 
142 }
parseInnerTree(array $elementMap=null)
Parses all elements below the current element.
Definition: Reader.php:129
WebDAV MultiStatus parser.
Definition: MultiStatus.php:22
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
__construct(array $responses, $syncToken=null)
Constructor.
Definition: MultiStatus.php:44
This is the XML element interface.
Definition: Element.php:18
xmlSerialize(Writer $writer)
The serialize method is called during xml writing.
Definition: MultiStatus.php:88
getSyncToken()
Returns the sync-token, if available.
Definition: MultiStatus.php:67
$response
getResponses()
Returns the response list.
Definition: MultiStatus.php:56
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