1<?php 2 3namespace Sabre\CalDAV\Xml\Request; 4 5use Sabre\Xml\Reader; 6use Sabre\Xml\XmlDeserializable; 7 8/** 9 * MKCALENDAR parser. 10 * 11 * This class parses the MKCALENDAR request, as defined in: 12 * 13 * https://tools.ietf.org/html/rfc4791#section-5.3.1 14 * 15 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 16 * @author Evert Pot (http://evertpot.com/) 17 * @license http://sabre.io/license/ Modified BSD License 18 */ 19class MkCalendar implements XmlDeserializable { 20 21 /** 22 * The list of properties that will be set. 23 * 24 * @var array 25 */ 26 public $properties = []; 27 28 /** 29 * Returns the list of properties the calendar will be initialized with. 30 * 31 * @return array 32 */ 33 function getProperties() { 34 35 return $this->properties; 36 37 } 38 39 /** 40 * The deserialize method is called during xml parsing. 41 * 42 * This method is called statictly, this is because in theory this method 43 * may be used as a type of constructor, or factory method. 44 * 45 * Often you want to return an instance of the current class, but you are 46 * free to return other data as well. 47 * 48 * You are responsible for advancing the reader to the next element. Not 49 * doing anything will result in a never-ending loop. 50 * 51 * If you just want to skip parsing for this element altogether, you can 52 * just call $reader->next(); 53 * 54 * $reader->parseInnerTree() will parse the entire sub-tree, and advance to 55 * the next element. 56 * 57 * @param Reader $reader 58 * @return mixed 59 */ 60 static function xmlDeserialize(Reader $reader) { 61 62 $self = new self(); 63 64 $elementMap = $reader->elementMap; 65 $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; 66 $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; 67 $elems = $reader->parseInnerTree($elementMap); 68 69 foreach ($elems as $elem) { 70 if ($elem['name'] === '{DAV:}set') { 71 $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); 72 } 73 } 74 75 return $self; 76 77 } 78 79} 80