fix calendar css, take 2. (#213)
[openemr.git] / interface / modules / zend_modules / library / Zend / XmlRpc / Server / System.php
blobc6aee9664cfc64c6639e218989c98bb158ff16ce
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\XmlRpc\Server;
12 /**
13 * XML-RPC system.* methods
15 class System
17 /**
18 * @var \Zend\XmlRpc\Server
20 protected $server;
22 /**
23 * Constructor
25 * @param \Zend\XmlRpc\Server $server
27 public function __construct(\Zend\XmlRpc\Server $server)
29 $this->server = $server;
32 /**
33 * List all available XMLRPC methods
35 * Returns an array of methods.
37 * @return array
39 public function listMethods()
41 $table = $this->server->getDispatchTable()->getMethods();
42 return array_keys($table);
45 /**
46 * Display help message for an XMLRPC method
48 * @param string $method
49 * @throws Exception\InvalidArgumentException
50 * @return string
52 public function methodHelp($method)
54 $table = $this->server->getDispatchTable();
55 if (!$table->hasMethod($method)) {
56 throw new Exception\InvalidArgumentException('Method "' . $method . '" does not exist', 640);
59 return $table->getMethod($method)->getMethodHelp();
62 /**
63 * Return a method signature
65 * @param string $method
66 * @throws Exception\InvalidArgumentException
67 * @return array
69 public function methodSignature($method)
71 $table = $this->server->getDispatchTable();
72 if (!$table->hasMethod($method)) {
73 throw new Exception\InvalidArgumentException('Method "' . $method . '" does not exist', 640);
75 $method = $table->getMethod($method)->toArray();
76 return $method['prototypes'];
79 /**
80 * Multicall - boxcar feature of XML-RPC for calling multiple methods
81 * in a single request.
83 * Expects an array of structs representing method calls, each element
84 * having the keys:
85 * - methodName
86 * - params
88 * Returns an array of responses, one for each method called, with the value
89 * returned by the method. If an error occurs for a given method, returns a
90 * struct with a fault response.
92 * @see http://www.xmlrpc.com/discuss/msgReader$1208
93 * @param array $methods
94 * @return array
96 public function multicall($methods)
98 $responses = array();
99 foreach ($methods as $method) {
100 $fault = false;
101 if (!is_array($method)) {
102 $fault = $this->server->fault('system.multicall expects each method to be a struct', 601);
103 } elseif (!isset($method['methodName'])) {
104 $fault = $this->server->fault('Missing methodName: ' . var_export($methods, 1), 602);
105 } elseif (!isset($method['params'])) {
106 $fault = $this->server->fault('Missing params', 603);
107 } elseif (!is_array($method['params'])) {
108 $fault = $this->server->fault('Params must be an array', 604);
109 } else {
110 if ('system.multicall' == $method['methodName']) {
111 // don't allow recursive calls to multicall
112 $fault = $this->server->fault('Recursive system.multicall forbidden', 605);
116 if (!$fault) {
117 try {
118 $request = new \Zend\XmlRpc\Request();
119 $request->setMethod($method['methodName']);
120 $request->setParams($method['params']);
121 $response = $this->server->handle($request);
122 if ($response instanceof \Zend\XmlRpc\Fault
123 || $response->isFault()
125 $fault = $response;
126 } else {
127 $responses[] = $response->getReturnValue();
129 } catch (\Exception $e) {
130 $fault = $this->server->fault($e);
134 if ($fault) {
135 $responses[] = array(
136 'faultCode' => $fault->getCode(),
137 'faultString' => $fault->getMessage()
142 return $responses;