You are here

function clients_connection_test_js in Web Service Clients 7.3

AJAX callback for test buttons.

1 string reference to 'clients_connection_test_js'
clients_connection_test_form in includes/clients.connection.admin.inc
Form to test a connection.

File

includes/clients.connection.admin.inc, line 457
clients.connection.admin.inc Page callbacks relating to client connection admin.

Code

function clients_connection_test_js($form, &$form_state) {

  //dsm($form_state);
  $connection = $form['#connection'];
  $type_definition = $form['#connection_type'];
  $test_name = $form_state['clicked_button']['#name'];
  $test_class = $type_definition['tests'][$test_name];
  $test_handler = new $test_class();

  // Only perform the test if the form has no errors.
  $errors = form_get_errors();
  if (!$errors) {

    // Only pass the method the values that are related to it; everything else is just cruft.
    $results = $test_handler
      ->test($connection, $form_state['values']['buttons'][$test_name]);
    $form['buttons'][$test_name]['results']['output'] = array(
      '#markup' => '<pre>' . check_plain(print_r($results, TRUE)) . '</pre>',
    );
  }

  // Place the data returned from the connection in the form for display.
  return $form['buttons'][$test_name]['results'];
}