2

I would like to put all my xmlrpc functions in a separate inc file and the problem is, how would we tell drupal it is in another file. Right now, my hook_xmlrpc in my module file looks like this:

function mymodule_xmlrpc() {

  $methods['mymodule.get_myfunction'] = 'xmls_mymodule_get_myfunction';
  return $methods;
}

xmls_mymodule_get_myfunction resides in mymodule.xml-rpc.inc file. How do we let drupal know that in this hook?

2 Answers 2

0

Why not just use xmls_mymodule_get_myfunction() as a proxy to the file where the real code is held?

function xmls_mymodule_get_myfunction($args) {
  module_load_include('inc', 'MYMODULE', 'MYMODULE.xml-rpc');
  _xmls_mymodule_get_myfunction($args);
}

You only incur 4 extra lines of code at the most, and you get the separation you're looking for. Obviously you can extend that function to become generic for several xmlrpc methods, the above is just a very simple example.

1
  • Yeah, I think this might be the best workaround. Thanks a bunch.
    – SN_26
    Commented Sep 7, 2012 at 8:24
1

Unfortunately, I don't believe you can.

Many core hooks, such as hook_menu, let's you define a file and a file path which Drupal can use to find the actual callbacks for the menu.

However, I don't believe this functionality is supported by hook_xmlrpc.

Considering also that the module is likely to leave core soon, it's unlikely that there will be any large improvements to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.