xref: /plugin/davcal/vendor/sabre/xml/lib/Element/Cdata.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\Xml\Element;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\Xml;
6*a1a3b679SAndreas Boehler
7*a1a3b679SAndreas Boehler/**
8*a1a3b679SAndreas Boehler * CDATA element.
9*a1a3b679SAndreas Boehler *
10*a1a3b679SAndreas Boehler * This element allows you to easily inject CDATA.
11*a1a3b679SAndreas Boehler *
12*a1a3b679SAndreas Boehler * Note that we strongly recommend avoiding CDATA nodes, unless you definitely
13*a1a3b679SAndreas Boehler * know what you're doing, or you're working with unchangable systems that
14*a1a3b679SAndreas Boehler * require CDATA.
15*a1a3b679SAndreas Boehler *
16*a1a3b679SAndreas Boehler * @copyright Copyright (C) 2009-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 Cdata implements Xml\XmlSerializable
21*a1a3b679SAndreas Boehler{
22*a1a3b679SAndreas Boehler    /**
23*a1a3b679SAndreas Boehler     * CDATA element value.
24*a1a3b679SAndreas Boehler     *
25*a1a3b679SAndreas Boehler     * @var string
26*a1a3b679SAndreas Boehler     */
27*a1a3b679SAndreas Boehler    protected $value;
28*a1a3b679SAndreas Boehler
29*a1a3b679SAndreas Boehler    /**
30*a1a3b679SAndreas Boehler     * Constructor
31*a1a3b679SAndreas Boehler     *
32*a1a3b679SAndreas Boehler     * @param string $value
33*a1a3b679SAndreas Boehler     */
34*a1a3b679SAndreas Boehler    function __construct($value)
35*a1a3b679SAndreas Boehler    {
36*a1a3b679SAndreas Boehler        $this->value = $value;
37*a1a3b679SAndreas Boehler    }
38*a1a3b679SAndreas Boehler
39*a1a3b679SAndreas Boehler    /**
40*a1a3b679SAndreas Boehler     * The xmlSerialize metod is called during xml writing.
41*a1a3b679SAndreas Boehler     *
42*a1a3b679SAndreas Boehler     * Use the $writer argument to write its own xml serialization.
43*a1a3b679SAndreas Boehler     *
44*a1a3b679SAndreas Boehler     * An important note: do _not_ create a parent element. Any element
45*a1a3b679SAndreas Boehler     * implementing XmlSerializble should only ever write what's considered
46*a1a3b679SAndreas Boehler     * its 'inner xml'.
47*a1a3b679SAndreas Boehler     *
48*a1a3b679SAndreas Boehler     * The parent of the current element is responsible for writing a
49*a1a3b679SAndreas Boehler     * containing element.
50*a1a3b679SAndreas Boehler     *
51*a1a3b679SAndreas Boehler     * This allows serializers to be re-used for different element names.
52*a1a3b679SAndreas Boehler     *
53*a1a3b679SAndreas Boehler     * If you are opening new elements, you must also close them again.
54*a1a3b679SAndreas Boehler     *
55*a1a3b679SAndreas Boehler     * @param Writer $writer
56*a1a3b679SAndreas Boehler     * @return void
57*a1a3b679SAndreas Boehler     */
58*a1a3b679SAndreas Boehler    function xmlSerialize(Xml\Writer $writer) {
59*a1a3b679SAndreas Boehler
60*a1a3b679SAndreas Boehler        $writer->writeCData($this->value);
61*a1a3b679SAndreas Boehler
62*a1a3b679SAndreas Boehler    }
63*a1a3b679SAndreas Boehler
64*a1a3b679SAndreas Boehler}
65