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_Api
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 resource abstract
29: *
30: * @category Mage
31: * @package Mage_Api
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_Api_Model_Resource_Abstract
35: {
36:
37: /**
38: * Resource configuration
39: *
40: * @var Varien_Simplexml_Element
41: */
42: protected $_resourceConfig = null;
43:
44: /**
45: * Retrieve webservice session
46: *
47: * @return Mage_Api_Model_Session
48: */
49: protected function _getSession()
50: {
51: return Mage::getSingleton('api/session');
52: }
53:
54: /**
55: * Retrieve webservice configuration
56: *
57: * @return Mage_Api_Model_Config
58: */
59: protected function _getConfig()
60: {
61: return Mage::getSingleton('api/config');
62: }
63:
64: /**
65: * Set configuration for api resource
66: *
67: * @param Varien_Simplexml_Element $xml
68: * @return Mage_Api_Model_Resource_Abstract
69: */
70: public function setResourceConfig(Varien_Simplexml_Element $xml)
71: {
72: $this->_resourceConfig = $xml;
73: return $this;
74: }
75:
76: /**
77: * Retrieve configuration for api resource
78: *
79: * @return Varien_Simplexml_Element
80: */
81: public function getResourceConfig()
82: {
83: return $this->_resourceConfig;
84: }
85:
86: /**
87: * Retrieve webservice server
88: *
89: * @return Mage_Api_Model_Server
90: */
91: protected function _getServer()
92: {
93: return Mage::getSingleton('api/server');
94: }
95:
96: /**
97: * Dispatches fault
98: *
99: * @param string $code
100: */
101: protected function _fault($code, $customMessage=null)
102: {
103: throw new Mage_Api_Exception($code, $customMessage);
104: }
105: } // Class Mage_Api_Model_Resource_Abstract End
106: