Checks whether a config directory exists and is writable.
This partially duplicates install_ensure_config_directory(), but is required since the installer would create the config directory too early in the installation process otherwise (e.g., when only visiting install.php when there is a settings.php already, but not actually executing the installation).
string $type: Type of config directory to return. Drupal core provides 'active' and 'staging'.
bool TRUE if the config directory exists and is writable.
function install_verify_config_directory($type) {
global $config_directories;
if (!isset($config_directories[$type])) {
return FALSE;
}
// config_get_config_directory() throws an exception when the passed $type
// does not exist in $config_directories. This can happen if there is a
// prepared settings.php that defines $config_directories already.
try {
$config_directory = config_get_config_directory($type);
if (is_dir($config_directory) && is_writable($config_directory)) {
return TRUE;
}
} catch (\Exception $e) {
}
return FALSE;
}