1.20.x config.inc config_get_config_directory($type = 'active')

Returns the path of a configuration directory.

Parameters

string $type: (optional) The type of config directory to return. Backdrop core provides 'active' and 'staging'. Defaults to 'active'.

Return value

string: The configuration directory path.

Throws

ConfigException

File

includes/config.inc, line 217
This is the API for configuration storage.

Code

function config_get_config_directory($type = 'active') {
  global $config_directories;

  if ($test_prefix = backdrop_valid_test_ua()) {
    // See BackdropWebTestBase::setUp().
    $path = conf_path() . '/files/simpletest/' . substr($test_prefix, 10) . '/config_' . $type;
  }
  elseif (!empty($config_directories[$type])) {
    $path = $config_directories[$type];

    // If the path contains a colon, assume it is a storage URL like
    // db:/default/config_active and return it directly.
    if (strpos($path, ':') !== FALSE) {
      return $path;
    }

    // If the path starts with a slash or dot, assume a normal path. If just
    // a directory name is provided, make it relative to the settings.php file.
    $first_character = substr($path, 0, 1);
    if (!in_array($first_character, array('.', '/', '\\'))) {
      $path = conf_path() . '/' . $path;
    }
  }
  else {
    throw new ConfigException(format_string('The configuration directory type "@type" does not exist.', array('@type' => $type)));
  }
  return $path;
}