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