function wsclient_tester_form_wsclient_service_form_alter in Web service client 7
Add our 'test' operation to the services overview form.
Implements hook_form_FORM_ID_alter().
See also
File
- wsclient_tester/
wsclient_tester.module, line 36 - Provides a UI for testing known services.
Code
function wsclient_tester_form_wsclient_service_form_alter(&$form, &$form_state) {
$service = $form_state['build_info']['args'][0];
// Avoid doing anything on new services that have no operation yet.
if (empty($form['operations'])) {
return;
}
foreach ($form['operations']['#rows'] as $operation => $row) {
if (!array_key_exists(0, $row)) {
// This is an additional non-data row in the table, contains extra operations.
continue;
}
$name = $row[0]['data']['#name'];
$form['operations']['#rows'][$operation][] = l(t('Test'), WSCLIENT_UI_PATH . '/manage/' . $service->name . '/operation/' . $name . '/test');
}
$form['operations']['#header'][1]['colspan'] += 1;
$last = count($form['operations']['#rows']) ? count($form['operations']['#rows']) - 1 : NULL;
if (!is_null($last) && is_numeric($last)) {
$form['operations']['#rows'][$last]['data'][0]['colspan'] += 1;
}
}