W3cubDocs

/Drupal 8

function 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 145
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");
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!includes!bootstrap.inc/function/config_get_config_directory/8.1.x