1<?php
2/**
3 * Handles appending XML to the document.
4 *
5 * PHP version 5
6 *
7 * @category Kolab
8 * @package  Kolab_Format
9 * @author   Gunnar Wrobel <wrobel@pardus.de>
10 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
11 * @link     http://www.horde.org/libraries/Horde_Kolab_Format
12 */
13
14/**
15 * Handles appending XML to the document.
16 *
17 * Copyright 2011-2016 Horde LLC (http://www.horde.org/)
18 *
19 * See the enclosed file COPYING for license information (LGPL). If you did not
20 * receive this file, see
21 * http://www.horde.org/licenses/lgpl21.
22 *
23 * @category Kolab
24 * @package  Kolab_Format
25 * @author   Gunnar Wrobel <wrobel@pardus.de>
26 * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
27 * @link     http://www.horde.org/libraries/Horde_Kolab_Format
28 */
29class Horde_Kolab_Format_Xml_Type_XmlAppend
30extends Horde_Kolab_Format_Xml_Type_Base
31{
32    /**
33     * Update the specified attribute.
34     *
35     * @param string                        $name        The name of the the
36     *                                                   attribute to be updated.
37     * @param array                         $attributes  The data array that holds
38     *                                                   all attribute values.
39     * @param DOMNode                       $parent_node The parent node of the
40     *                                                   node that should be
41     *                                                   updated.
42     * @param Horde_Kolab_Format_Xml_Helper $helper      A XML helper instance.
43     * @param array                         $params      Additional parameters
44     *                                                   for this write operation.
45     *
46     * @return DOMNode|boolean The new/updated child node or false if this
47     *                         failed.
48     *
49     * @throws Horde_Kolab_Format_Exception If converting the data to XML failed.
50     */
51    public function save(
52        $name,
53        $attributes,
54        $parent_node,
55        Horde_Kolab_Format_Xml_Helper $helper,
56        $params = array()
57    )
58    {
59        $value = $this->generateWriteValue($name, $attributes, $params);
60        return empty($value) ? false : $helper->appendXml(
61            $parent_node, $value
62        );
63    }
64}
65