As we use class RESTServer for our REST server I think it will be very good feature to let users use inheritance here.

Practically what I mean is to add new attribute to hook_server_info named "class".

In this case in services_endpoint_callback() instead of calling

print call_user_func($server . '_server');

We would load server class and run:

  try {
    $server = new $server_class;
    return $server->handle($canonical_path, $endpoint_path);
  }
  catch (Exception $e) {
    $server->handleException($e);
  }

And if developer will need to change some behavior inside the class he can easily change the class of server using hook_server_info_alter and inherit his own class from RESTServer.

Comments

marcingy’s picture

This won't work with xmlrpc as it is not a class, that would mean that we need to rewrite xmlrpc as a class and have a defined base class for all servers. Which is itself a good idea but I'm not certain it is a 7.3 thing because it requires a major rewrite of sub system. If xmlrpc was no longer in core of course this would be much easier.

ygerasimov’s picture

Status: Active » Postponed

@marcingy truly to say we know that xmlrpc is not in the best shape anyway and it would be good to rewrite it.

But lets postpone this issue.

marcingy’s picture

This looks like an ideal 7.4 target.

kylebrowning’s picture

Status: Postponed » Closed (won't fix)

Wont fix in 3.x but ive added it as a list of things to do for 4.x