config_get_config_directory

config_get_config_directory($type)

Returns the path of a configuration directory.

Configuration directories are configured using $config_directories in settings.php.

Parameters

string $type: The type of config directory to return. Drupal core provides the CONFIG_SYNC_DIRECTORY constant to access the sync directory.

Return value

string The configuration directory path.

Throws

\Exception

File

core/includes/bootstrap.inc, line 147
Functions that need to be loaded on every Drupal request.

Code

function config_get_config_directory($type) {
  global $config_directories;

  // @todo Remove fallback in Drupal 9. https://www.drupal.org/node/2574943
  if ($type == CONFIG_SYNC_DIRECTORY && !isset($config_directories[CONFIG_SYNC_DIRECTORY]) && isset($config_directories[CONFIG_STAGING_DIRECTORY])) {
    $type = CONFIG_STAGING_DIRECTORY;
  }

  if (!empty($config_directories[$type])) {
    return $config_directories[$type];
  }
  // @todo https://www.drupal.org/node/2696103 Throw a more specific exception.
  throw new \Exception("The configuration directory type '$type' does not exist");
}
doc_Drupal
2016-10-29 08:55:23
Comments
Leave a Comment

Please login to continue.