ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
SupportedCalendarComponentSet.php
Go to the documentation of this file.
1 <?php
2 
4 
10 
25 
33  protected $components = [];
34 
40  function __construct(array $components) {
41 
42  $this->components = $components;
43 
44  }
45 
51  function getValue() {
52 
53  return $this->components;
54 
55  }
56 
76  function xmlSerialize(Writer $writer) {
77 
78  foreach ($this->components as $component) {
79 
80  $writer->startElement('{' . Plugin::NS_CALDAV . '}comp');
81  $writer->writeAttributes(['name' => $component]);
82  $writer->endElement();
83 
84  }
85 
86  }
87 
109  static function xmlDeserialize(Reader $reader) {
110 
111  $elems = $reader->parseInnerTree();
112 
113  $components = [];
114 
115  foreach ((array)$elems as $elem) {
116  if ($elem['name'] === '{' . Plugin::NS_CALDAV . '}comp') {
117  $components[] = $elem['attributes']['name'];
118  }
119  }
120 
121  if (!$components) {
122  throw new ParseException('supported-calendar-component-set must have at least one CALDAV:comp element');
123  }
124 
125  return new self($components);
126 
127  }
128 
129 }
parseInnerTree(array $elementMap=null)
Parses all elements below the current element.
Definition: Reader.php:129
startElement($name)
Opens a new element.
Definition: Writer.php:121
The Reader class expands upon PHP&#39;s built-in XMLReader.
Definition: Reader.php:20
xmlSerialize(Writer $writer)
The xmlSerialize method is called during xml writing.
Exception thrown by Reader if an invalid object was attempted to be parsed.
This is the XML element interface.
Definition: Element.php:18
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
writeAttributes(array $attributes)
Writes a list of attributes.
Definition: Writer.php:211
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
The XML Writer class.
Definition: Writer.php:31