* @param string $namespace
* @param string $encoding
*/
- public function __construct($namespace) {
+ public function __construct($namespace)
+ {
$this->namespace = $namespace;
self::initialize();
}
/**
* Destructor
*/
- public function __destruct() {
+ public function __destruct()
+ {
if (self::$refcnt && !--self::$refcnt) {
xmlrpc_server_destroy(self::$xmlrpc);
}
* @param string $namespace
* @return XmlRpcServer
*/
- public static function factory($namespace) {
+ public static function factory($namespace)
+ {
return new XmlRpcServer($namespace);
}
*
* @param array $options
*/
- public static function run(array $options = null) {
+ public static function run(array $options = null)
+ {
self::initialize(false, true);
- HttpResponse::setContentType("text/xml; charset=". self::$encoding);
+ self::setContentType("text/xml; charset=". self::$encoding);
echo xmlrpc_server_call_method(self::$xmlrpc, self::$xmlreq, null,
array("encoding" => self::$encoding) + (array) $options);
}
* @param array $params
* @param array $options
*/
- public static function test($method, array $params, array $options = null) {
+ public static function test($method, array $params, array $options = null)
+ {
self::$xmlreq = xmlrpc_encode_request($method, $params);
self::run();
}
* @param int $code
* @param string $msg
*/
- public static function error($code, $msg) {
+ public static function error($code, $msg)
+ {
echo xmlrpc_encode(array("faultCode" => $code, "faultString" => $msg));
}
* @param mixed $dispatch
* @param array $spec
*/
- public function registerMethod($name, $callback, $dispatch = null, array $spec = null) {
+ public function registerMethod($name, $callback, $dispatch = null, array $spec = null)
+ {
if (!is_callable($callback, false, $cb_name)) {
throw new Exception("$cb_name is not a valid callback");
}
*
* @param XmlRpcRequestHandler $handler
*/
- public function registerHandler(XmlRpcRequestHandler $handler) {
+ public function registerHandler(XmlRpcRequestHandler $handler)
+ {
$this->handler = $handler;
foreach (get_class_methods($handler) as $method) {
}
}
- private function method($method, $namespace = null) {
+ private function method($method, $namespace = null)
+ {
if (!strlen($namespace)) {
$namespace = strlen($this->namespace) ? $this->namespace : "xmlrpc";
}
return $namespace .".". strtolower($method[6]) . substr($method, 7);
}
- private function dispatch($method, array $params = null) {
+ private function dispatch($method, array $params = null)
+ {
if (array_key_exists($method, self::$handle)) {
return call_user_func(self::$handle[$method], $params);
}
throw new Exception("Unknown XMLRPC method: $method");
}
- private static function initialize($server = true, $data = false) {
+ private static function initialize($server = true, $data = false)
+ {
if ($data) {
if (!self::$xmlreq && !(self::$xmlreq = http_get_request_body())) {
throw new Exception("Failed to fetch XMLRPC request body");
* }
* </code>
*/
-interface XmlRpcRequestHandler {
+interface XmlRpcRequestHandler
+{
public function getNamespace();
public function getIntrospectionData(array &$spec = null);
}
/**
* XmlRpcRequestHandlerStub
*/
-abstract class XmlRpcRequestHandlerStub implements XmlRpcRequestHandler {
- public function getNamespace() {
+abstract class XmlRpcRequestHandlerStub implements XmlRpcRequestHandler
+{
+ public function getNamespace()
+ {
}
- public function getIntrospectionData(array &$spec = null) {
+ public function getIntrospectionData(array &$spec = null)
+ {
}
}