function key_get_key_value in Key 7.3
Get a key value using a key configuration.
Parameters
array|string $config: The configuration id or array for the key value to retrieve.
Return value
string The key value.
6 calls to key_get_key_value()
- KeyBasicAdminTest::testConfigKeyProvider in ./
key.test - Test the Configuration key provider.
- KeyBasicAdminTest::testFileKeyProvider in ./
key.test - Test the File key provider.
- key_config_form_validate in includes/
key.admin.inc - Form validate handler for key_config_form().
- key_encrypt_key_get_key in modules/
key_encrypt/ plugins/ key_providers/ key.inc - Callback function to return the key.
- _drush_key_value_get in drush/
key_value_get.inc - Get a key value.
File
- ./
key.module, line 660 - Main Key functionality and hook implementations.
Code
function key_get_key_value($config) {
$keys =& drupal_static(__FUNCTION__);
// If $config is an array, it must be a configuration ID.
if (!is_array($config)) {
$config_id = $config;
}
else {
$config_id = isset($config['id']) ? $config['id'] : '';
}
// If the key has already been retrieved during this page load, return it.
if (isset($keys[$config_id])) {
return $keys[$config_id];
}
if (!is_array($config)) {
$config = key_get_key($config_id);
}
// If the configuration doesn't exist, return NULL.
if (!isset($config)) {
return NULL;
}
$provider = key_get_plugin('key_provider', $config['key_provider']);
// Get the function to retrieve the key.
$key_function = ctools_plugin_get_function($provider, 'get key value');
// Retrieve the key.
$key = call_user_func($key_function, $config);
// Store the key, in case it's needed again.
$keys[$config_id] = $key;
return $key;
}