1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_Api2
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * API XML Renderer Writer
29: *
30: * @category Mage
31: * @package Mage_Api2
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Api2_Model_Renderer_Xml_Writer extends Zend_Config_Writer_Xml
35: {
36: /**
37: * Root node in XML output
38: */
39: const XML_ROOT_NODE = 'magento_api';
40:
41: /**
42: * Render a Zend_Config into a XML config string.
43: * OVERRIDE to avoid using zend-config string in XML
44: *
45: * @return string
46: */
47: public function render()
48: {
49: $xml = new SimpleXMLElement('<' . self::XML_ROOT_NODE . '/>');
50: $extends = $this->_config->getExtends();
51: $sectionName = $this->_config->getSectionName();
52:
53: if (is_string($sectionName)) {
54: $child = $xml->addChild($sectionName);
55:
56: $this->_addBranch($this->_config, $child, $xml);
57: } else {
58: foreach ($this->_config as $sectionName => $data) {
59: if (!($data instanceof Zend_Config)) {
60: $xml->addChild($sectionName, (string) $data);
61: } else {
62: $child = $xml->addChild($sectionName);
63:
64: if (isset($extends[$sectionName])) {
65: $child->addAttribute('zf:extends', $extends[$sectionName], Zend_Config_Xml::XML_NAMESPACE);
66: }
67:
68: $this->_addBranch($data, $child, $xml);
69: }
70: }
71: }
72:
73: $dom = dom_import_simplexml($xml)->ownerDocument;
74: $dom->formatOutput = true;
75:
76: $xmlString = $dom->saveXML();
77:
78: return $xmlString;
79: }
80: }
81: