forked from OpenMage/magento-lts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
191 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
app/code/core/Mage/Api/Model/Server/Adapter/Jsonrpc.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available at https://opensource.org/license/osl-3-0-php | ||
* | ||
* @category Mage | ||
* @package Mage | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) | ||
* @copyright Copyright (c) 2020 The OpenMage Contributors (https://www.openmage.org) | ||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* @category Mage | ||
* @package Mage_Api | ||
*/ | ||
class Mage_Api_Model_Server_Adapter_Jsonrpc extends Varien_Object implements Mage_Api_Model_Server_Adapter_Interface | ||
{ | ||
protected $_jsonRpc = null; | ||
|
||
/** | ||
* Set handler class name for webservice | ||
* | ||
* @param string $handler | ||
* @return $this | ||
*/ | ||
public function setHandler($handler) | ||
{ | ||
$this->setData('handler', $handler); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve handler class name for webservice | ||
* | ||
* @return string | ||
*/ | ||
public function getHandler() | ||
{ | ||
return $this->getData('handler'); | ||
} | ||
|
||
/** | ||
* Set webservice api controller | ||
* | ||
* @param Mage_Api_Controller_Action $controller | ||
* @return $this | ||
*/ | ||
public function setController(Mage_Api_Controller_Action $controller) | ||
{ | ||
$this->setData('controller', $controller); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Retrieve webservice api controller. If no controller have been set - emulate it by the use of Varien_Object | ||
* | ||
* @return Mage_Api_Controller_Action|Varien_Object | ||
*/ | ||
public function getController() | ||
{ | ||
$controller = $this->getData('controller'); | ||
|
||
if (null === $controller) { | ||
$controller = new Varien_Object( | ||
array('request' => Mage::app()->getRequest(), 'response' => Mage::app()->getResponse()) | ||
); | ||
|
||
$this->setData('controller', $controller); | ||
} | ||
return $controller; | ||
} | ||
|
||
/** | ||
* Run webservice | ||
* | ||
* @return $this | ||
*/ | ||
public function run() | ||
{ | ||
$this->_jsonRpc = new Zend_Json_Server(); | ||
$this->_jsonRpc->setClass($this->getHandler()); | ||
$this->getController()->getResponse() | ||
->clearHeaders() | ||
->setHeader('Content-Type', 'application/json; charset=utf8') | ||
->setBody($this->_jsonRpc->handle()); | ||
return $this; | ||
} | ||
|
||
/** | ||
* Dispatch webservice fault | ||
* | ||
* @param int $code | ||
* @param string $message | ||
*/ | ||
public function fault($code, $message) | ||
{ | ||
throw new Zend_Json_Exception($message, $code); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* OpenMage | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available at https://opensource.org/license/osl-3-0-php | ||
* | ||
* @category Mage | ||
* @package Mage_Api | ||
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) | ||
* @copyright Copyright (c) 2020-2022 The OpenMage Contributors (https://www.openmage.org) | ||
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
|
||
/** | ||
* Webservice main controller | ||
* | ||
* @category Mage | ||
* @package Mage_Api | ||
*/ | ||
class Mage_Api_JsonrpcController extends Mage_Api_Controller_Action | ||
{ | ||
public function indexAction() | ||
{ | ||
$this->_getServer()->init($this, 'jsonrpc') | ||
->run(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.