You are here

function clients_connection_drupal_services_7_3::testConnectionNodeLoad in Web Service Clients 6.2

Same name and namespace in other branches
  1. 7.2 connections/clients_drupal/clients_drupal.inc \clients_connection_drupal_services_7_3::testConnectionNodeLoad()

Connection test button handler: loading a node: Services 7.x-3.x.

Overrides clients_connection_drupal_services::testConnectionNodeLoad

File

connections/clients_drupal/clients_drupal.inc, line 331
Contains classes for Client connections handlers.

Class

clients_connection_drupal_services_7_3
Drupal client for services on a Drupal 7 site for Services 7.x-3.x.

Code

function testConnectionNodeLoad(&$button_form_values) {

  // Must be cast to integer for faffiness of XMLRPC and Services.
  $nid = (int) $button_form_values['nid'];
  try {
    $node = $this
      ->callMethodArray('node.retrieve', array(
      $nid,
    ));
  } catch (Exception $e) {
    drupal_set_message(t('Could not retrieve a node from the remote site, got error message "@message".', array(
      '@message' => $e
        ->getMessage(),
    )), 'warning');

    //dsm($e);
    return;
  }
  if (is_array($node) && isset($node['nid'])) {
    drupal_set_message(t('Sucessfully retrieved node %title (nid @nid).', array(
      '%title' => $node['title'],
      '@nid' => $node['nid'],
    )));
  }
  else {
    drupal_set_message(t('Could not retrieve a node from the remote site.'), 'warning');
  }
  return $node;
}