You are here

function hook_xmlrpc_alter in xmlrpc 8

Alters the definition of XML-RPC methods before they are called.

This hook allows modules to modify the callback definition of declared XML-RPC methods, right before they are invoked by a client. Methods may be added, or existing methods may be altered.

Note that hook_xmlrpc() supports two distinct and incompatible formats to define a callback, so care must be taken when altering other methods.

Parameters

array $methods: An asssociative array of method callback definitions, as returned from hook_xmlrpc() implementations.

See also

hook_xmlrpc()

xmlrpc_server()

2 functions implement hook_xmlrpc_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

xmlrpc_example_xmlrpc_alter in xmlrpc_example/xmlrpc_example.module
Implements hook_xmlrpc_alter().
xmlrpc_test_xmlrpc_alter in tests/modules/xmlrpc_test/xmlrpc_test.module
Implements hook_xmlrpc_alter().
1 invocation of hook_xmlrpc_alter()
xmlrpc_server in ./xmlrpc.server.inc
Invokes XML-RPC methods on this server.

File

./xmlrpc.api.php, line 72
Hooks provided by the XML-RPC module.

Code

function hook_xmlrpc_alter(array &$methods) {

  // Directly change a simple method.
  $methods['drupal.login'] = 'mymodule_login';

  // Alter complex definitions.
  foreach ($methods as $key => &$method) {

    // Skip simple method definitions.
    if (!is_int($key)) {
      continue;
    }

    // Perform the wanted manipulation.
    if ($method[0] == 'drupal.site.ping') {
      $method[1] = 'mymodule_directory_ping';
    }
  }
}