1<?php
2
3namespace Sabre\DAV\Xml\Property;
4
5use Sabre\DAV\Xml\Element\Sharee;
6use Sabre\Xml\Writer;
7use Sabre\Xml\XmlSerializable;
8
9/**
10 * This class represents the {DAV:}invite property.
11 *
12 * This property is defined here:
13 * https://tools.ietf.org/html/draft-pot-webdav-resource-sharing-03#section-4.4.2
14 *
15 * This property is used by clients to determine who currently has access to
16 * a shared resource, what their access level is and what their invite status
17 * is.
18 *
19 * @copyright Copyright (C) fruux GmbH (https://fruux.com/).
20 * @author Evert Pot (http://evertpot.com/)
21 * @license http://sabre.io/license/ Modified BSD License
22 */
23class Invite implements XmlSerializable {
24
25    /**
26     * A list of sharees
27     *
28     * @var Sharee[]
29     */
30    public $sharees = [];
31
32    /**
33     * Creates the property.
34     *
35     * @param Sharee[] $sharees
36     */
37    function __construct(array $sharees) {
38
39        $this->sharees = $sharees;
40
41    }
42
43    /**
44     * The xmlSerialize method is called during xml writing.
45     *
46     * Use the $writer argument to write its own xml serialization.
47     *
48     * An important note: do _not_ create a parent element. Any element
49     * implementing XmlSerializable should only ever write what's considered
50     * its 'inner xml'.
51     *
52     * The parent of the current element is responsible for writing a
53     * containing element.
54     *
55     * This allows serializers to be re-used for different element names.
56     *
57     * If you are opening new elements, you must also close them again.
58     *
59     * @param Writer $writer
60     * @return void
61     */
62    function xmlSerialize(Writer $writer) {
63
64        foreach ($this->sharees as $sharee) {
65            $writer->writeElement('{DAV:}sharee', $sharee);
66        }
67
68    }
69
70}
71