+ $code = $code . $plist . ") {\n" . $innerCode . "\n}\n";
+
+ return array('source' => $code, 'docstring' => $mDesc);
+ }
+
+ /**
+ * Similar to wrapXmlrpcMethod, but will generate a php class that wraps
+ * all xmlrpc methods exposed by the remote server as own methods.
+ * For more details see wrapXmlrpcMethod.
+ *
+ * For a slimmer alternative, see the code in demo/client/proxy.php
+ *
+ * Note that unlike wrapXmlrpcMethod, we always have to generate php code here. It seems that php 7 will have anon classes...
+ *
+ * @param Client $client the client obj all set to query the desired server
+ * @param array $extraOptions list of options for wrapped code. See the ones from wrapXmlrpcMethod plus
+ * - string method_filter regular expression
+ * - string new_class_name
+ * - string prefix
+ * - bool simple_client_copy set it to true to avoid copying all properties of $client into the copy made in the new class
+ *
+ * @return mixed false on error, the name of the created class if all ok or an array with code, class name and comments (if the appropriate option is set in extra_options)
+ */
+ public function wrapXmlrpcServer($client, $extraOptions = array())
+ {
+ $methodFilter = isset($extraOptions['method_filter']) ? $extraOptions['method_filter'] : '';
+ $timeout = isset($extraOptions['timeout']) ? (int)$extraOptions['timeout'] : 0;
+ $protocol = isset($extraOptions['protocol']) ? $extraOptions['protocol'] : '';
+ $newClassName = isset($extraOptions['new_class_name']) ? $extraOptions['new_class_name'] : '';
+ $encodePhpObjects = isset($extraOptions['encode_php_objs']) ? (bool)$extraOptions['encode_php_objs'] : false;
+ $decodePhpObjects = isset($extraOptions['decode_php_objs']) ? (bool)$extraOptions['decode_php_objs'] : false;
+ $verbatimClientCopy = isset($extraOptions['simple_client_copy']) ? !($extraOptions['simple_client_copy']) : true;
+ $buildIt = isset($extraOptions['return_source']) ? !($extraOptions['return_source']) : true;
+ $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
+ $namespace = '\\PhpXmlRpc\\';
+
+ $reqClass = $namespace . 'Request';
+ $decoderClass = $namespace . 'Encoder';
+
+ $req = new $reqClass('system.listMethods');
+ $response = $client->send($req, $timeout, $protocol);
+ if ($response->faultCode()) {
+ $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve method list from remote server');
+
+ return false;
+ } else {
+ $mList = $response->value();
+ if ($client->return_type != 'phpvals') {
+ $decoder = new $decoderClass();
+ $mList = $decoder->decode($mList);
+ }
+ if (!is_array($mList) || !count($mList)) {
+ $this->getLogger()->errorLog('XML-RPC: ' . __METHOD__ . ': could not retrieve meaningful method list from remote server');