You are here

function key_get_key in Key 7.2

Same name and namespace in other branches
  1. 7.3 key.module \key_get_key()
  2. 7 key.module \key_get_key()

Get a key using a key configuration.

Parameters

string $config_name: The configuration name of the key to retrieve.

Return value

string The key.

2 calls to key_get_key()
key_config_form in includes/key.admin.inc
Form constructor for the key configuration edit form.
key_encrypt_key_get_key in modules/key_encrypt/plugins/key_providers/key.inc
Callback function to return the key.

File

./key.module, line 434
Provides the ability to manage keys, which can be used by other modules.

Code

function key_get_key($config_name) {
  $keys =& drupal_static(__FUNCTION__);

  // If the key already exists, return it.
  if (isset($keys[$config_name])) {
    return $keys[$config_name];
  }
  $config = key_get_config($config_name);

  // If the configuration doesn't exist, return NULL.
  if (!isset($config)) {
    return NULL;
  }
  $provider = key_get_provider($config['provider']);

  // Get the function to retrieve the key.
  $key_function = ctools_plugin_get_function($provider, 'key get value');

  // Retrieve the key.
  $key = call_user_func($key_function, $config);

  // Store the key, in case it's needed again.
  $keys[$config_name] = $key;
  return $key;
}