1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31: 32: 33:
34: class Mage_Api_Model_Wsdl_Config extends Mage_Api_Model_Wsdl_Config_Base
35: {
36: protected static $_namespacesPrefix = null;
37:
38: public function __construct($sourceData=null)
39: {
40: $this->setCacheId('wsdl_config_global');
41: parent::__construct($sourceData);
42: }
43:
44: 45: 46: 47: 48:
49: public function getWsdlContent()
50: {
51: return $this->_xml->asXML();
52: }
53:
54: 55: 56: 57: 58:
59: public static function getNamespacesPrefix()
60: {
61: if (is_null(self::$_namespacesPrefix)) {
62: self::$_namespacesPrefix = array();
63: $config = Mage::getSingleton('api/config')->getNode('v2/wsdl/prefix')->children();
64: foreach ($config as $prefix => $namespace) {
65: self::$_namespacesPrefix[$namespace->asArray()] = $prefix;
66: }
67: }
68: return self::$_namespacesPrefix;
69: }
70:
71: public function getCache()
72: {
73: return Mage::app()->getCache();
74: }
75:
76: protected function _loadCache($id)
77: {
78: return Mage::app()->loadCache($id);
79: }
80:
81: protected function _saveCache($data, $id, $tags=array(), $lifetime=false)
82: {
83: return Mage::app()->saveCache($data, $id, $tags, $lifetime);
84: }
85:
86: protected function _removeCache($id)
87: {
88: return Mage::app()->removeCache($id);
89: }
90:
91: public function init()
92: {
93: $this->setCacheChecksum(null);
94: $saveCache = true;
95:
96: if (Mage::app()->useCache('config')) {
97: $loaded = $this->loadCache();
98: if ($loaded) {
99: return $this;
100: }
101: }
102:
103: $mergeWsdl = new Mage_Api_Model_Wsdl_Config_Base();
104: $mergeWsdl->setHandler($this->getHandler());
105:
106: if(Mage::helper('api/data')->isComplianceWSI()){
107: 108: 109: 110:
111: $mergeWsdl->addLoadedFile(Mage::getConfig()->getModuleDir('etc', "Mage_Api").DS.'wsi.xml');
112:
113: $baseWsdlFile = Mage::getConfig()->getModuleDir('etc', "Mage_Api").DS.'wsi.xml';
114: $this->loadFile($baseWsdlFile);
115: Mage::getConfig()->loadModulesConfiguration('wsi.xml', $this, $mergeWsdl);
116: } else {
117: 118: 119: 120:
121: $mergeWsdl->addLoadedFile(Mage::getConfig()->getModuleDir('etc', "Mage_Api").DS.'wsdl.xml');
122:
123: $baseWsdlFile = Mage::getConfig()->getModuleDir('etc', "Mage_Api").DS.'wsdl2.xml';
124: $this->loadFile($baseWsdlFile);
125: Mage::getConfig()->loadModulesConfiguration('wsdl.xml', $this, $mergeWsdl);
126: }
127:
128: if (Mage::app()->useCache('config')) {
129: $this->saveCache(array('config'));
130: }
131:
132: return $this;
133: }
134:
135: 136: 137: 138: 139:
140: public function getXmlString()
141: {
142: return $this->getNode()->asXML();
143: }
144: }
145: