1<?php
2
3namespace Sabre\DAV\Xml\Request;
4
5use Sabre\Xml\Element\KeyValue;
6use Sabre\Xml\Reader;
7use Sabre\Xml\XmlDeserializable;
8
9/**
10 * WebDAV PROPFIND request parser.
11 *
12 * This class parses the {DAV:}propfind request, as defined in:
13 *
14 * https://tools.ietf.org/html/rfc4918#section-14.20
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 PropFind implements XmlDeserializable {
21
22    /**
23     * If this is set to true, this was an 'allprop' request.
24     *
25     * @var bool
26     */
27    public $allProp = false;
28
29    /**
30     * The property list
31     *
32     * @var null|array
33     */
34    public $properties;
35
36    /**
37     * The deserialize method is called during xml parsing.
38     *
39     * This method is called statictly, this is because in theory this method
40     * may be used as a type of constructor, or factory method.
41     *
42     * Often you want to return an instance of the current class, but you are
43     * free to return other data as well.
44     *
45     * You are responsible for advancing the reader to the next element. Not
46     * doing anything will result in a never-ending loop.
47     *
48     * If you just want to skip parsing for this element altogether, you can
49     * just call $reader->next();
50     *
51     * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
52     * the next element.
53     *
54     * @param Reader $reader
55     * @return mixed
56     */
57    static function xmlDeserialize(Reader $reader) {
58
59        $self = new self();
60
61        $reader->pushContext();
62        $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements';
63
64        foreach (KeyValue::xmlDeserialize($reader) as $k => $v) {
65
66            switch ($k) {
67                case '{DAV:}prop' :
68                    $self->properties = $v;
69                    break;
70                case '{DAV:}allprop' :
71                    $self->allProp = true;
72
73            }
74
75        }
76
77        $reader->popContext();
78
79        return $self;
80
81    }
82
83}
84