You are here

function _s3fs_get_config in S3 File System 7.2

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

Returns the current s3fs configuration settings.

The functions in S3 File System which utilize variables always accept a config array instead of calling variable_get() themselves. This allows for their callers to override these configuration settings when necessary (like when attempting to validate new settings).

Parameters

$reset bool: This function uses a static cache for performance reasons. Passing TRUE will reset that cache.

Return value

array An associative array of all the s3fs_* config settings, with the "s3fs_" prefix removed from their names. Also includes any awsdsk2_ prefixed vars, with their prefix left intact.

13 calls to _s3fs_get_config()
drush_s3fs_copy_local in ./s3fs.drush.inc
Copys all files from the local public/private filesystem folders into S3, if s3fs is configured to take over those systems.
drush_s3fs_refresh_cache in ./s3fs.drush.inc
Refreshes the file metadata cache.
s3fs.test in tests/s3fs.test
S3fsStreamWrapper::__construct in ./S3fsStreamWrapper.inc
Stream wrapper constructor.
s3fs_actions in ./s3fs.admin.inc
Builds the Actions form.

... See full list

File

./s3fs.module, line 827
Hook implementations and other primary functionality for S3 File System.

Code

function _s3fs_get_config($reset = FALSE) {
  $config =& drupal_static('_s3fs_get_config');
  if ($config === NULL || $reset) {

    // The global $conf array contains all the variables, including overrides
    // from settings.php.
    global $conf;
    $config = array();
    foreach ($conf as $key => $value) {

      // Retrieve the s3fs_ prefixed vars, and strip the prefix.
      if (substr($key, 0, 5) == 's3fs_') {
        $config[substr($key, 5)] = $value;
      }
    }
    foreach ($conf as $key => $value) {

      // Retrieve the awssdk2_ prefixed vars, but don't strip the prefix.
      // These will override any s3fs_awssdk2_ prefixed vars.
      if (substr($key, 0, 8) == 'awssdk2_') {
        $config[$key] = $value;
      }
    }

    // Remove any leading or trailing slashes from these settings, in case the user added them.
    if (!empty($config['root_folder'])) {
      $config['root_folder'] = trim($config['root_folder'], '\\/');
    }
    if (!empty($config['public_folder'])) {
      $config['public_folder'] = trim($config['public_folder'], '\\/');
    }
    if (!empty($config['private_folder'])) {
      $config['private_folder'] = trim($config['private_folder'], '\\/');
    }
  }
  return $config;
}