abstract class clients_connection_base in Web Service Clients 6.2
Same name and namespace in other branches
- 7.3 includes/clients.entity.inc \clients_connection_base
- 7 clients.inc \clients_connection_base
- 7.2 clients.inc \clients_connection_base
Base class for client connections.
Hierarchy
- class \clients_connection_base
Expanded class hierarchy of clients_connection_base
File
- ./
clients.inc, line 10 - Contains basic classes for client connections.
View source
abstract class clients_connection_base {
/**
* The machine name of the connection.
*/
public $name;
/**
* The connection id. Only set if this is stored in the database.
*/
public $cid;
/**
* The URL this connection connects to.
*/
public $endpoint;
/**
* An array of further configuration options.
*/
public $configuration;
// ============================================ Connection UI
/**
* Format the connection's endpoint as a link.
*
* @param $url
* The connection's endpoint.
*
* @return
* The string to display in the admin UI. Subclasses may format this as a
* link to the remote site.
*/
function formatEndpoint($url) {
return $url;
}
/**
* Extra form elements specific to a class's edit form.
*
* This is the same pattern as node_form() -- just ignore the object behind
* the curtain ;)
*
* This (so far) is common to all versions of Drupal Services.
*
* @param $form_state
* The form state from the main form, which you probably don't need anyway.
*
* @return
* A FormAPI form array. This will be merged in with basic data and the
* submit button added.
*
* @see clients_connection_form()
* @see clients_connection_form()
* @see clients_connection_form_submit()
*/
function connectionSettingsForm(&$form_state) {
$form = array();
return $form;
}
/**
* Submit handler for saving/updating connections of this class.
*
* @see clients_connection_form_submit().
*/
static function connectionSettingsForm_submit($form, &$form_state) {
// Base class does nothing; saving of the connection is handled by the
// 'real' FormAPI submit handler.
}
/**
* Provide buttons for the connection testing page.
*/
function getTestOperations($form_state, $connection_name) {
return array();
}
// ============================================ Constructor.
/**
* Constructor method.
*
* @param $object
* An object of class stdClass returned from CTools.
*/
function __construct($object) {
// Lump all data unto the object...
foreach ((array) $object as $field => $value) {
$this->{$field} = $value;
}
// Connections defined in code are already unserialized.
if (!is_array($object->configuration)) {
$this->configuration = unserialize($object->configuration);
}
return $this;
}
// ============================================ Connection API.
/**
* Call a remote method.
*
* This is a wrapper around callMethodArray that gives the convenience of
* being able to pass method name and parameters as one flat list, and hence
* is the main API for connection objects.
*
* @param $method
* The name of the remote method to call.
* @param ...
* All other parameters are passed to the remote method.
*
* @return
* Whatever is returned from the remote site.
*
* @throws Exception on error from the remote site.
*/
function callMethod($method) {
// Get all the arguments this function has been passed.
$function_args = func_get_args();
// Slice out the ones that are arguments to the method call: everything past
// the 1st argument.
$method_params = array_slice($function_args, 1);
return $this
->callMethodArray($method, $method_params);
}
/**
* Call a remote method with an array of parameters.
*
* This is intended for internal use from callMethod() and
* clients_connection_call().
* If you need to call a method on given connection object, use callMethod
* which has a nicer form.
*
* @param $method
* The name of the remote method to call.
* @param $method_params
* An array of parameters to passed to the remote method.
*
* @return
* Whatever is returned from the remote site.
*
* @throws Exception on error from the remote site.
* It's up to subclasses to implement this, as the test for an error and
* the way to get information about it varies according to service type.
*/
function callMethodArray($method, $method_params = array()) {
// Up to subclasses to override this to do something.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
clients_connection_base:: |
public | property | The connection id. Only set if this is stored in the database. | |
clients_connection_base:: |
public | property | An array of further configuration options. | |
clients_connection_base:: |
public | property | The URL this connection connects to. | |
clients_connection_base:: |
public | property | The machine name of the connection. | |
clients_connection_base:: |
function | Call a remote method. | ||
clients_connection_base:: |
function | Call a remote method with an array of parameters. | 3 | |
clients_connection_base:: |
function | Extra form elements specific to a class's edit form. | 2 | |
clients_connection_base:: |
static | function | Submit handler for saving/updating connections of this class. | 2 |
clients_connection_base:: |
function | Format the connection's endpoint as a link. | 2 | |
clients_connection_base:: |
function | Provide buttons for the connection testing page. | 1 | |
clients_connection_base:: |
function | Constructor method. | 2 |