xref: /plugin/davcal/vendor/sabre/dav/lib/CalDAV/Xml/Property/EmailAddressSet.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\CalDAV\Xml\Property;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\Xml\Writer;
6*a1a3b679SAndreas Boehleruse Sabre\Xml\XmlSerializable;
7*a1a3b679SAndreas Boehler
8*a1a3b679SAndreas Boehler/**
9*a1a3b679SAndreas Boehler * email-address-set property
10*a1a3b679SAndreas Boehler *
11*a1a3b679SAndreas Boehler * This property represents the email-address-set property in the
12*a1a3b679SAndreas Boehler * http://calendarserver.org/ns/ namespace.
13*a1a3b679SAndreas Boehler *
14*a1a3b679SAndreas Boehler * It's a list of email addresses associated with a user.
15*a1a3b679SAndreas Boehler *
16*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/).
17*a1a3b679SAndreas Boehler * @author Evert Pot (http://evertpot.com/)
18*a1a3b679SAndreas Boehler * @license http://sabre.io/license/ Modified BSD License
19*a1a3b679SAndreas Boehler */
20*a1a3b679SAndreas Boehlerclass EmailAddressSet implements XmlSerializable {
21*a1a3b679SAndreas Boehler
22*a1a3b679SAndreas Boehler    /**
23*a1a3b679SAndreas Boehler     * emails
24*a1a3b679SAndreas Boehler     *
25*a1a3b679SAndreas Boehler     * @var array
26*a1a3b679SAndreas Boehler     */
27*a1a3b679SAndreas Boehler    private $emails;
28*a1a3b679SAndreas Boehler
29*a1a3b679SAndreas Boehler    /**
30*a1a3b679SAndreas Boehler     * __construct
31*a1a3b679SAndreas Boehler     *
32*a1a3b679SAndreas Boehler     * @param array $emails
33*a1a3b679SAndreas Boehler     */
34*a1a3b679SAndreas Boehler    function __construct(array $emails) {
35*a1a3b679SAndreas Boehler
36*a1a3b679SAndreas Boehler        $this->emails = $emails;
37*a1a3b679SAndreas Boehler
38*a1a3b679SAndreas Boehler    }
39*a1a3b679SAndreas Boehler
40*a1a3b679SAndreas Boehler    /**
41*a1a3b679SAndreas Boehler     * Returns the email addresses
42*a1a3b679SAndreas Boehler     *
43*a1a3b679SAndreas Boehler     * @return array
44*a1a3b679SAndreas Boehler     */
45*a1a3b679SAndreas Boehler    function getValue() {
46*a1a3b679SAndreas Boehler
47*a1a3b679SAndreas Boehler        return $this->emails;
48*a1a3b679SAndreas Boehler
49*a1a3b679SAndreas Boehler    }
50*a1a3b679SAndreas Boehler
51*a1a3b679SAndreas Boehler    /**
52*a1a3b679SAndreas Boehler     * The xmlSerialize metod is called during xml writing.
53*a1a3b679SAndreas Boehler     *
54*a1a3b679SAndreas Boehler     * Use the $writer argument to write its own xml serialization.
55*a1a3b679SAndreas Boehler     *
56*a1a3b679SAndreas Boehler     * An important note: do _not_ create a parent element. Any element
57*a1a3b679SAndreas Boehler     * implementing XmlSerializble should only ever write what's considered
58*a1a3b679SAndreas Boehler     * its 'inner xml'.
59*a1a3b679SAndreas Boehler     *
60*a1a3b679SAndreas Boehler     * The parent of the current element is responsible for writing a
61*a1a3b679SAndreas Boehler     * containing element.
62*a1a3b679SAndreas Boehler     *
63*a1a3b679SAndreas Boehler     * This allows serializers to be re-used for different element names.
64*a1a3b679SAndreas Boehler     *
65*a1a3b679SAndreas Boehler     * If you are opening new elements, you must also close them again.
66*a1a3b679SAndreas Boehler     *
67*a1a3b679SAndreas Boehler     * @param Writer $writer
68*a1a3b679SAndreas Boehler     * @return void
69*a1a3b679SAndreas Boehler     */
70*a1a3b679SAndreas Boehler    function xmlSerialize(Writer $writer) {
71*a1a3b679SAndreas Boehler
72*a1a3b679SAndreas Boehler        foreach ($this->emails as $email) {
73*a1a3b679SAndreas Boehler
74*a1a3b679SAndreas Boehler            $writer->writeElement('{http://calendarserver.org/ns/}email-address', $email);
75*a1a3b679SAndreas Boehler
76*a1a3b679SAndreas Boehler        }
77*a1a3b679SAndreas Boehler
78*a1a3b679SAndreas Boehler    }
79*a1a3b679SAndreas Boehler
80*a1a3b679SAndreas Boehler}
81