You are here

function awssdk_config_defaults in AWS SDK for PHP 7.3

Same name and namespace in other branches
  1. 7.4 awssdk.module \awssdk_config_defaults()

Load the default AWSSDK settings.

Return value

An associative array containing default settings, or FALSE.

1 call to awssdk_config_defaults()
awssdk_config_load in ./awssdk.module
Load the default AWSSDK settings and apply variable overrides.

File

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

Code

function awssdk_config_defaults() {
  $info = libraries_load('awssdk');

  // Attempt to load the sample configuration file provided with AWSSDK.
  if (file_exists($sample_config = $info['library path'] . '/config-sample.inc.php')) {

    // Use a regular expression to determine the default values for the
    // configuration constants instead of including the file so that the
    // constants are never defined in the current process to prevent possible
    // conflicts that might occur if caches are cleared when the AWSSDK is
    // attempting to be used.
    $contents = file_get_contents($sample_config);
    if (preg_match_all("/define\\('(\\w+)', (.*)\\);/", $contents, $matches, PREG_SET_ORDER)) {
      $defaults = array();
      foreach ($matches as $match) {
        $defaults[$match[1]] = eval('return ' . $match[2] . ';');
      }
      return $defaults;
    }
  }
  return FALSE;
}