You are here

function clients_get_connection in Web Service Clients 7

Same name and namespace in other branches
  1. 6.2 clients.module \clients_get_connection()

Create a connection object which can then be used to make method calls.

Usage: $client = clients_get_connection($cid); $client->callMethod('node.load', array(1));

Parameters

$cid: The id of a connection.

1 call to clients_get_connection()
clients_connection_test_form in ./clients.connection.admin.inc
Page callback to test a connection.

File

./clients.module, line 304
Clients module - handles keys and service connections and provides an API for clients

Code

function clients_get_connection($cid) {

  // TODO: Look at how flag module does this, as it's the same principle --
  // create an object of a particular class based on settings -- and the
  // pattern there may be better.
  $connection_types = clients_get_connection_types();
  $connection_data = clients_connection_load($cid);
  if (isset($connection_types[$connection_data->type])) {
    $class = 'clients_connection_' . $connection_data->type;
    $connection = new $class($connection_data);
  }
  else {

    // error, but we would only get here if the DB held a type that no longer had a hook...
  }
  return $connection;
}