function xmlrpc_example_xmlrpc_alter

Implements hook_xmlrpc_alter().

Check to see if xmlrpc_example.add and xmlrpc_example.subtract methods are defined and replace their callbacks with custom code.

See also

hook_xmlrpc_alter()

Related topics

File

xmlrpc_example/xmlrpc_example.module, line 622

Code

function xmlrpc_example_xmlrpc_alter(&$methods) {
    // Only perform alterations if instructed to do so.
    if (!variable_get('xmlrpc_example_alter_enabled', 0)) {
        return;
    }
    // Loop all defined methods (other modules may include additional methods).
    foreach ($methods as $index => $method) {
        // First element in the method array is the method name.
        if ($method[0] == 'xmlrpc_example.add') {
            // Replace current callback with custom callback
            // (second argument of the array).
            $methods[$index][1] = '_xmlrpc_example_alter_add';
        }
        // Do the same for the substraction method.
        if ($method[0] == 'xmlrpc_example.subtract') {
            $methods[$index][1] = '_xmlrpc_example_alter_subtract';
        }
    }
}