modjsonrpcresponse.class.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of MODX Revolution.
  4. *
  5. * Copyright (c) MODX, LLC. All Rights Reserved.
  6. *
  7. * For complete copyright and license information, see the COPYRIGHT and LICENSE
  8. * files found in the top-level directory of this distribution.
  9. */
  10. require_once MODX_CORE_PATH . 'model/modx/xmlrpc/modxmlrpcresponse.class.php';
  11. require_once MODX_CORE_PATH . 'model/modx/jsonrpc/jsonrpc.inc';
  12. require_once MODX_CORE_PATH . 'model/modx/jsonrpc/jsonrpcs.inc';
  13. /**
  14. * Extends modXMLRPCResponse to support servicing JSON-RPC client requests.
  15. *
  16. * @package modx
  17. * @subpackage jsonrpc
  18. */
  19. class modJSONRPCResponse extends modXMLRPCResponse {
  20. /**
  21. * Output the content of this response
  22. * @param array $options An array of options for the output
  23. * @return void
  24. */
  25. public function outputContent(array $options= array()) {
  26. if (empty($options['rpc_type'])) $options['rpc_type']= 'JSON';
  27. parent :: outputContent($options);
  28. }
  29. /**
  30. * Load the JSON-RPC server
  31. * @param bool $execute Execute the server process
  32. * @return bool True if the server was successfully loaded
  33. */
  34. public function getServer($execute= false) {
  35. if ($this->server === null || !($this->server instanceof jsonrpc_server)) {
  36. $this->server= new jsonrpc_server($this->services, $execute);
  37. }
  38. return $this->server instanceof jsonrpc_server;
  39. }
  40. }