You are here

function key_get_key in Key 7

Same name and namespace in other branches
  1. 7.3 key.module \key_get_key()
  2. 7.2 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.

1 call to key_get_key()
key_ui_key_config_form in modules/key_ui/includes/key_ui.admin.inc
Form constructor for the key configuration edit form.

File

./key.module, line 670
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);
  $provider = key_get_provider($config['provider']);

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

  // If there are any settings, use them.
  $provider_settings = isset($config['provider_settings']) ? $config['provider_settings'] : array();

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

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