00001 <?php 00002 /** 00003 * Magento 00004 * 00005 * NOTICE OF LICENSE 00006 * 00007 * This source file is subject to the Open Software License (OSL 3.0) 00008 * that is bundled with this package in the file LICENSE.txt. 00009 * It is also available through the world-wide-web at this URL: 00010 * http://opensource.org/licenses/osl-3.0.php 00011 * If you did not receive a copy of the license and are unable to 00012 * obtain it through the world-wide-web, please send an email 00013 * to license@magentocommerce.com so we can send you a copy immediately. 00014 * 00015 * DISCLAIMER 00016 * 00017 * Do not edit or add to this file if you wish to upgrade Magento to newer 00018 * versions in the future. If you wish to customize Magento for your 00019 * needs please refer to http://www.magentocommerce.com for more information. 00020 * 00021 * @category Mage 00022 * @package Mage_Api 00023 * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) 00024 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) 00025 */ 00026 00027 /** 00028 * Api resource abstract 00029 * 00030 * @category Mage 00031 * @package Mage_Api 00032 * @author Magento Core Team <core@magentocommerce.com> 00033 */ 00034 class Mage_Api_Model_Resource_Abstract 00035 { 00036 00037 /** 00038 * Resource configuration 00039 * 00040 * @var Varien_Simplexml_Element 00041 */ 00042 protected $_resourceConfig = null; 00043 00044 /** 00045 * Retrieve webservice session 00046 * 00047 * @return Mage_Api_Model_Session 00048 */ 00049 protected function _getSession() 00050 { 00051 return Mage::getSingleton('api/session'); 00052 } 00053 00054 /** 00055 * Retrieve webservice configuration 00056 * 00057 * @return Mage_Api_Model_Config 00058 */ 00059 protected function _getConfig() 00060 { 00061 return Mage::getSingleton('api/config'); 00062 } 00063 00064 /** 00065 * Set configuration for api resource 00066 * 00067 * @param Varien_Simplexml_Element $xml 00068 * @return Mage_Api_Model_Resource_Abstract 00069 */ 00070 public function setResourceConfig(Varien_Simplexml_Element $xml) 00071 { 00072 $this->_resourceConfig = $xml; 00073 return $this; 00074 } 00075 00076 /** 00077 * Retrieve configuration for api resource 00078 * 00079 * @return Varien_Simplexml_Element 00080 */ 00081 public function getResourceConfig() 00082 { 00083 return $this->_resourceConfig; 00084 } 00085 00086 /** 00087 * Retrieve webservice server 00088 * 00089 * @return Mage_Api_Model_Server 00090 */ 00091 protected function _getServer() 00092 { 00093 return Mage::getSingleton('api/server'); 00094 } 00095 00096 /** 00097 * Dispatches fault 00098 * 00099 * @param string $code 00100 */ 00101 protected function _fault($code, $customMessage=null) 00102 { 00103 throw new Mage_Api_Exception($code, $customMessage); 00104 } 00105 } // Class Mage_Api_Model_Resource_Abstract End