class clients_credentials_storage_variable in Web Service Clients 7.3
Plugin handler class.
Store credentials in the Connection's configuration array (i.e., the same as the old way!). This means that the credentials are contained within the exported connection, which may or may not be desirable depending on your situation.
Hierarchy
Expanded class hierarchy of clients_credentials_storage_variable
1 string reference to 'clients_credentials_storage_variable'
- variables.inc in plugins/
clients_credentials_storage/ variables.inc
File
- plugins/
clients_credentials_storage/ variables.inc, line 23
View source
class clients_credentials_storage_variable {
/**
* Helper to get the variable name.
*
* @param $connection
* The connection to use.
*/
function variableName($connection) {
// TODO: This can cause problems if the connection name is too long:
// character limit for a system variable name is 128, but so is that for
// a connection name!
return 'clients_connection_credentials_' . $connection->name;
}
/**
* Load credentials, if any exist, into the connection.
*
* @param $connection
* The connection to load credentials from.
*/
public function credentialsLoad($connection) {
$credentials = variable_get($this
->variableName($connection), array());
foreach ($credentials as $property_name => $value) {
$connection->credentials[$property_name] = $value;
}
}
/**
* Save credentials.
*
* @param $connection
* The connection to save credentials for. These should be present in the
* $connection->credentials array, where the form submit process will have
* placed them.
*/
public function credentialsSave($connection) {
// Get the list of properties which are credentials.
$credentials = array();
$credentials_properties = $connection
->credentialsProperties();
// Build an array of credentials to save.
foreach ($credentials_properties as $property_name) {
$credentials[$property_name] = $connection->credentials[$property_name];
}
variable_set($this
->variableName($connection), $credentials);
}
/**
* Erase credentials.
*
* This should be called when a connection is deleted, or when a connection
* changes its credentials storage mechanism.
*
* @param $connection
* The connection to delete credentials for.
*/
public function credentialsDelete($connection) {
variable_del($this
->variableName($connection));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
clients_credentials_storage_variable:: |
public | function | Erase credentials. | |
clients_credentials_storage_variable:: |
public | function | Load credentials, if any exist, into the connection. | |
clients_credentials_storage_variable:: |
public | function | Save credentials. | |
clients_credentials_storage_variable:: |
function | Helper to get the variable name. |