Page 1 of 1

Extending the TestlinkXMLRPCServer class

Posted: Wed Jan 20, 2010 7:00 pm
by rtessier
Here's a suggestion I've found really useful for our deployment of the Testlink XML-RPC server.

I've split xmlrpc.php into two files: xmlrpc_class.php which includes the class definition and xmlrpc.php which has the following two lines:

require_once("xmlrpc_class.php");
$XMLRPCServer = new TestlinkXMLRCPServer();

Then, I modified the TestlinkXMLRPCServer constructor to accept an optional array of methods:

...
public function __construct($callbacks = array()) {
...

Finally, I added the following line right before calling the IXR_Server constructor:

...
$this->methods += $callbacks;
...

This allows a subclass to add its own methods without modifying the base class. This is very useful for me to add methods that I need but aren't yet implemented in the base class. These "extended" methods could then eventually be submitted for inclusion in the base class. in which case the base class definition would override the subclass definition.

i.e.

class MyClass extends TestlinkXMLRPCServer {
public funtion __construct() {
$callbacks = array( 'tl.getTestSuiteIDByName' => 'this:getTestSuiteIDByName' );
parent::__construct($callbacks);
}

public function getTestSuiteIDByName() {
...
}
}

Please consider adding this change to the API, I believe it could be very useful for many people.

Keep up the good work!
Robin

Posted: Fri Jan 22, 2010 8:33 pm
by fman
Please: submit this into mantis as feature request