diff options
author | Dries Buytaert <dries@buytaert.net> | 2009-12-13 13:06:45 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2009-12-13 13:06:45 +0000 |
commit | a1e08d9353e60d7a1093ea1cf1afc507870078d9 (patch) | |
tree | 864757b706e4264b83412d4a1954c2bb08025c48 | |
parent | ab6f592cd72b0ed0b33a962985004d19969da479 (diff) | |
download | brdo-a1e08d9353e60d7a1093ea1cf1afc507870078d9.tar.gz brdo-a1e08d9353e60d7a1093ea1cf1afc507870078d9.tar.bz2 |
- Patch #656266 by fgm: fixed the hook and added documentation.
-rw-r--r-- | modules/system/system.api.php | 38 | ||||
-rw-r--r-- | xmlrpc.php | 2 |
2 files changed, 39 insertions, 1 deletions
diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 820e351ec..bf499efd3 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -1129,6 +1129,44 @@ function hook_xmlrpc() { } /** + * Alter the definition of XML-RPC methods before they are called. + * + * This hook lets at module modify the callback definition for already + * declared XML-RPC methods, when they are being invoked by a client. + * + * This hook is invoked by xmlrpc.php. The method definitions are + * passed in by reference. Each element of the $methods array is one + * callback definition returned by a module from hook_xmlrpc. Additional + * methods may be added, or existing items altered. + * + * Modules implementing this hook must take care of the fact that + * hook_xmlrpc allows two distinct and incompatible formats for callback + * definition, so module must be prepared to handle either format for + * each callback being altered. + * + * @see hook_xmlrpc() + * + * @param $methods + * Associative array of method callback definitions returned from + * hook_xmlrpc. + */ +function hook_xmlrpc_alter(&$methods) { + + // Direct update for methods defined the simple way + $methods['drupal.login'] = 'mymodule_login'; + + // Lookup update for methods defined the complex way + foreach ($methods as $key => &$method) { + if (!is_int($key)) { + continue; + } + if ($method[0] == 'drupal.site.ping') { + $method[1] = 'mymodule_directory_ping'; + } + } +} + +/** * Log an event message * * This hook allows modules to route log events to custom destinations, such as diff --git a/xmlrpc.php b/xmlrpc.php index fee29fd5e..5787f5b19 100644 --- a/xmlrpc.php +++ b/xmlrpc.php @@ -17,5 +17,5 @@ include_once DRUPAL_ROOT . '/includes/xmlrpc.inc'; include_once DRUPAL_ROOT . '/includes/xmlrpcs.inc'; $services = module_invoke_all('xmlrpc'); -drupal_alter('xmlrpc_alter', $services); +drupal_alter('xmlrpc', $services); xmlrpc_server($services); |