ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
CalendarData.php
Go to the documentation of this file.
1<?php
2
4
10
29
51 static function xmlDeserialize(Reader $reader) {
52
53 $result = [
54 'contentType' => $reader->getAttribute('content-type') ?: 'text/calendar',
55 'version' => $reader->getAttribute('version') ?: '2.0',
56 ];
57
58 $elems = (array)$reader->parseInnerTree();
59 foreach ($elems as $elem) {
60
61 switch ($elem['name']) {
62 case '{' . Plugin::NS_CALDAV . '}expand' :
63
64 $result['expand'] = [
65 'start' => isset($elem['attributes']['start']) ? DateTimeParser::parseDateTime($elem['attributes']['start']) : null,
66 'end' => isset($elem['attributes']['end']) ? DateTimeParser::parseDateTime($elem['attributes']['end']) : null,
67 ];
68
69 if (!$result['expand']['start'] || !$result['expand']['end']) {
70 throw new BadRequest('The "start" and "end" attributes are required when expanding calendar-data');
71 }
72 if ($result['expand']['end'] <= $result['expand']['start']) {
73 throw new BadRequest('The end-date must be larger than the start-date when expanding calendar-data');
74 }
75 break;
76 }
77
78 }
79
80 return $result;
81
82 }
83
84}
$result
An exception for terminatinating execution or to throw for unit testing.
CalDAV plugin.
Definition: Plugin.php:28
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
static xmlDeserialize(Reader $reader)
The deserialize method is called during xml parsing.
static parseDateTime($dt, DateTimeZone $tz=null)
Parses an iCalendar (rfc5545) formatted datetime and returns a DateTimeImmutable object.
The Reader class expands upon PHP's built-in XMLReader.
Definition: Reader.php:20
Implementing the XmlDeserializable interface allows you to use a class as a deserializer for a specif...