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