Overview

Packages

  • currencysymbol
  • MAbout
  • Mage
    • Admin
    • Adminhtml
    • AdminNotification
    • Api
    • Api2
    • Authorizenet
    • Backup
    • Bundle
    • Captcha
    • Catalog
    • CatalogIndex
    • CatalogInventory
    • CatalogRule
    • CatalogSearch
    • Centinel
    • Checkout
    • Cms
    • Compiler
    • Connect
    • Contacts
    • Core
    • Cron
    • CurrencySymbol
    • Customer
    • Dataflow
    • Directory
    • DirtectPost
    • Downloadable
    • Eav
    • GiftMessage
    • GoogleAnalytics
    • GoogleBase
    • GoogleCheckout
    • ImportExport
    • Index
    • Install
    • Log
    • Media
    • Newsletter
    • Oauth
    • Page
    • PageCache
    • Paygate
    • Payment
    • Paypal
    • PaypalUk
    • Persistent
    • Poll
    • ProductAlert
    • Rating
    • Reports
    • Review
    • Rss
    • Rule
    • Sales
    • SalesRule
    • Sedfriend
    • Sendfriend
    • Shipping
    • Sitemap
    • Tag
    • Tax
    • Usa
    • Weee
    • Widget
    • Wishlist
    • XmlConnect
  • None
  • Phoenix
    • Moneybookers
  • PHP
  • Zend
    • Date
    • Mime
    • XmlRpc

Classes

  • Mage_Api_Controller_Action
  • Mage_Api_Helper_Data
  • Mage_Api_IndexController
  • Mage_Api_Model_Acl
  • Mage_Api_Model_Acl_Assert_Ip
  • Mage_Api_Model_Acl_Assert_Time
  • Mage_Api_Model_Acl_Resource
  • Mage_Api_Model_Acl_Role
  • Mage_Api_Model_Acl_Role_Generic
  • Mage_Api_Model_Acl_Role_Group
  • Mage_Api_Model_Acl_Role_Registry
  • Mage_Api_Model_Acl_Role_User
  • Mage_Api_Model_Config
  • Mage_Api_Model_Mysql4_Acl
  • Mage_Api_Model_Mysql4_Acl_Role
  • Mage_Api_Model_Mysql4_Acl_Role_Collection
  • Mage_Api_Model_Mysql4_Permissions_Collection
  • Mage_Api_Model_Mysql4_Role
  • Mage_Api_Model_Mysql4_Role_Collection
  • Mage_Api_Model_Mysql4_Roles
  • Mage_Api_Model_Mysql4_Roles_Collection
  • Mage_Api_Model_Mysql4_Roles_User_Collection
  • Mage_Api_Model_Mysql4_Rules
  • Mage_Api_Model_Mysql4_Rules_Collection
  • Mage_Api_Model_Mysql4_User
  • Mage_Api_Model_Mysql4_User_Collection
  • Mage_Api_Model_Resource_Abstract
  • Mage_Api_Model_Resource_Acl
  • Mage_Api_Model_Resource_Acl_Role
  • Mage_Api_Model_Resource_Acl_Role_Collection
  • Mage_Api_Model_Resource_Permissions_Collection
  • Mage_Api_Model_Resource_Role
  • Mage_Api_Model_Resource_Role_Collection
  • Mage_Api_Model_Resource_Roles
  • Mage_Api_Model_Resource_Roles_Collection
  • Mage_Api_Model_Resource_Roles_User_Collection
  • Mage_Api_Model_Resource_Rules
  • Mage_Api_Model_Resource_Rules_Collection
  • Mage_Api_Model_Resource_User
  • Mage_Api_Model_Resource_User_Collection
  • Mage_Api_Model_Role
  • Mage_Api_Model_Roles
  • Mage_Api_Model_Rules
  • Mage_Api_Model_Server
  • Mage_Api_Model_Server_Adapter_Soap
  • Mage_Api_Model_Server_Adapter_Xmlrpc
  • Mage_Api_Model_Server_Handler
  • Mage_Api_Model_Server_Handler_Abstract
  • Mage_Api_Model_Server_V2_Adapter_Soap
  • Mage_Api_Model_Server_V2_Handler
  • Mage_Api_Model_Server_WSI_Adapter_Soap
  • Mage_Api_Model_Server_WSI_Handler
  • Mage_Api_Model_Session
  • Mage_Api_Model_User
  • Mage_Api_Model_Wsdl_Config
  • Mage_Api_Model_Wsdl_Config_Base
  • Mage_Api_SoapController
  • Mage_Api_V2_SoapController
  • Mage_Api_XmlrpcController

Interfaces

  • Mage_Api_Model_Server_Adapter_Interface

Exceptions

  • Mage_Api_Exception
  • Overview
  • Package
  • Class
  • Tree
  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:  * Webservices server handler WSI
 29:  *
 30:  * @category   Mage
 31:  * @package    Mage_Api
 32:  * @author     Magento Core Team <core@magentocommerce.com>
 33:  */
 34: class Mage_Api_Model_Server_WSI_Handler extends Mage_Api_Model_Server_Handler_Abstract
 35: {
 36:     protected $_resourceSuffix = '_v2';
 37: 
 38:     /**
 39:      * Interceptor for all interfaces
 40:      *
 41:      * @param string $function
 42:      * @param array $args
 43:      */
 44: 
 45:     public function __call ($function, $args)
 46:     {
 47:         $args = $args[0];
 48: 
 49:         /** @var Mage_Api_Helper_Data */
 50:         $helper = Mage::helper('api/data');
 51: 
 52:         $helper->wsiArrayUnpacker($args);
 53:         $args = get_object_vars($args);
 54: 
 55:         if(isset($args['sessionId'])){
 56:             $sessionId = $args['sessionId'];
 57:             unset($args['sessionId']);
 58:         } else {
 59:             // Was left for backward compatibility.
 60:             $sessionId = array_shift( $args );
 61:         }
 62: 
 63:         $apiKey = '';
 64:         $nodes = Mage::getSingleton('api/config')->getNode('v2/resources_function_prefix')->children();
 65:         foreach ($nodes as $resource => $prefix) {
 66:             $prefix = $prefix->asArray();
 67:             if (false !== strpos($function, $prefix)) {
 68:                 $method = substr($function, strlen($prefix));
 69:                 $apiKey = $resource . '.' . strtolower($method[0]).substr($method, 1);
 70:             }
 71:         }
 72: 
 73:         list($modelName, $methodName) = $this->_getResourceName($apiKey);
 74:         $methodParams = $this->getMethodParams($modelName, $methodName);
 75: 
 76:         $args = $this->prepareArgs($methodParams, $args);
 77: 
 78:         $res = $this->call($sessionId, $apiKey, $args);
 79: 
 80:         $obj = $helper->wsiArrayPacker($res);
 81:         $stdObj = new stdClass();
 82:         $stdObj->result = $obj;
 83: 
 84:         return $stdObj;
 85:     }
 86: 
 87:     /**
 88:      * Login user and Retrieve session id
 89:      *
 90:      * @param string $username
 91:      * @param string $apiKey
 92:      * @return string
 93:      */
 94:     public function login($username, $apiKey = null)
 95:     {
 96:         if (is_object($username)) {
 97:             $apiKey = $username->apiKey;
 98:             $username = $username->username;
 99:         }
100: 
101:         $stdObject = new stdClass();
102:         $stdObject->result = parent::login($username, $apiKey);
103:         return $stdObject;
104:     }
105: 
106:     /**
107:      * Return called class and method names
108:      *
109:      * @param String $apiPath
110:      * @return Array
111:      */
112:     protected function _getResourceName($apiPath){
113: 
114:         list($resourceName, $methodName) = explode('.', $apiPath);
115: 
116:         if (empty($resourceName) || empty($methodName)) {
117:             return $this->_fault('resource_path_invalid');
118:         }
119: 
120:         $resourcesAlias = $this->_getConfig()->getResourcesAlias();
121:         $resources      = $this->_getConfig()->getResources();
122:         if (isset($resourcesAlias->$resourceName)) {
123:             $resourceName = (string) $resourcesAlias->$resourceName;
124:         }
125: 
126:         $methodInfo = $resources->$resourceName->methods->$methodName;
127: 
128:         $modelName = $this->_prepareResourceModelName((string) $resources->$resourceName->model);
129: 
130:         $modelClass = Mage::getConfig()->getModelClassName($modelName);
131: 
132:         $method = (isset($methodInfo->method) ? (string) $methodInfo->method : $methodName);
133: 
134:         return array($modelClass, $method);
135:     }
136: 
137:     /**
138:      * Return an array of parameters for the callable method.
139:      *
140:      * @param String $modelName
141:      * @param String $methodName
142:      * @return Array of ReflectionParameter
143:      */
144:     public function getMethodParams($modelName, $methodName) {
145: 
146:         $method = new ReflectionMethod($modelName, $methodName);
147: 
148:         return $method->getParameters();
149:     }
150: 
151:     /**
152:      * Prepares arguments for the method calling. Sort in correct order, set default values for omitted parameters.
153:      *
154:      * @param Array $params
155:      * @param Array $args
156:      * @return Array
157:      */
158:     public function prepareArgs($params, $args) {
159: 
160:         $callArgs = array();
161: 
162:         /** @var $parameter ReflectionParameter */
163:         foreach($params AS $parameter){
164:             $pName = $parameter->getName();
165:             if( isset( $args[$pName] ) ){
166:                 $callArgs[$pName] = $args[$pName];
167:             } else {
168:                 if($parameter->isOptional()){
169:                     $callArgs[$pName] = $parameter->getDefaultValue();
170:                 } else {
171:                     Mage::logException(new Exception("Required parameter \"$pName\" is missing.", 0));
172:                     $this->_fault('invalid_request_param');
173:                 }
174:             }
175:         }
176:         return $callArgs;
177:     }
178: 
179: }
180: 
Magento 1.7.0.2 API documentation generated by ApiGen 2.8.0