You are here

function config_get_config_directory in Drupal 8

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

Deprecated

in drupal:8.8.0 and is removed from drupal:9.0.0. Use \Drupal\Core\Site\Settings::get('config_sync_directory') instead.

See also

https://www.drupal.org/node/3018145

6 calls to config_get_config_directory()
BootstrapConfigStorageFactory::getFileStorage in core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
Returns a File-based configuration storage implementation.
ConfigImporterTest::testConfigGetConfigDirectory in core/tests/Drupal/KernelTests/Core/Config/ConfigImporterTest.php
Tests config_get_config_directory().
drupal_install_config_directories in core/includes/install.inc
Creates the config directory and ensures it is operational.
FileStorageFactory::getActive in core/lib/Drupal/Core/Config/FileStorageFactory.php
Returns a FileStorage object working with the active config directory.
install_ensure_config_directory in core/includes/install.inc
Ensures that the config directory exists and is writable, or can be made so.

... See full list

File

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

Code

function config_get_config_directory($type) {
  global $config_directories;
  @trigger_error('config_get_config_directory() is deprecated in drupal:8.8.0 and is removed from drupal:9.0.0. Use \\Drupal\\Core\\Site\\Settings::get(\'config_sync_directory\') instead. See https://www.drupal.org/node/3018145', E_USER_DEPRECATED);
  $config_sync_directory = Settings::get('config_sync_directory', FALSE);
  if ($config_sync_directory) {
    $config_directories[CONFIG_SYNC_DIRECTORY] = $config_sync_directory;
  }

  // @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");
}