You are here

function clients_connection_get_substituted_name in Web Service Clients 7.3

Get the name of the connection that is being substituted for.

Parameters

$connection_name: The name of a connection in use.

Return value

If the given connection is being used as an environment substitute for another, then the name of the inactive connection which is being replaced. For example, given 'connection_dev' in the 'dev' environment, this returns 'connection'. If no connection substitution is occurring, the given name is returned unchanged.

File

./clients.module, line 214
Clients module provides a UI, storage, and an API for handling connections to remote webservices, including those provided by Services module on other Drupal sites.

Code

function clients_connection_get_substituted_name($connection_name) {
  $environment_name = variable_get('environment_name', NULL);
  if (substr($connection_name, -1 * strlen($environment_name)) == $environment_name) {
    $original_connection_name = substr($connection_name, 0, -1 * (strlen($environment_name) + 1));
    if ($original_connection = entity_load_single('clients_connection', $original_connection_name)) {
      return $original_connection->name;
    }
  }
  return $connection_name;
}