You are here

function awssdk_config_load in AWS SDK for PHP 7.5

Same name and namespace in other branches
  1. 7.3 awssdk.module \awssdk_config_load()
  2. 7.4 awssdk.module \awssdk_config_load()

Load the default AWSSDK settings and apply variable overrides.

Return value

An associative array containing AWSSDK setting values.

2 calls to awssdk_config_load()
AWSSDKUnitTest::testLibrary in ./awssdk.test
Ensure that AWS SDK libraries integration and configuration work properly.
awssdk_config_set in ./awssdk.module
Set configuration via CFCredentials::set() during library load.
1 string reference to 'awssdk_config_load'
awssdk_ui_settings_form_submit in ui/awssdk_ui.module
Clear config cache to new settings take effect.

File

./awssdk.module, line 106
Provides primary Drupal hook implementations.

Code

function awssdk_config_load() {
  if (!($config =& drupal_static(__FUNCTION__))) {
    $config = ($cache = cache_get(__FUNCTION__)) ? $cache->data : array();
  }
  if (!$config) {
    $keys = array(
      // Required keys.
      'key',
      'secret',
      'account_id',
      'canonical_id',
      // Optional keys.
      'canonical_name',
      'certificate_authority',
      'default_cache_config',
      'mfa_serial',
      'cloudfront_keypair',
      'cloudfront_pem',
    );

    // Look for variables for each key and pull in the values.
    foreach ($keys as $key) {
      if (($value = variable_get('aws_' . $key)) !== NULL) {
        $config[$key] = $value;
      }
    }

    // Merge required defaults.
    $config += array(
      'default_cache_config' => '',
      'certificate_authority' => FALSE,
    );
    cache_set(__FUNCTION__, $config);
  }
  return $config;
}