function drupal_install_config_directories in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/includes/install.inc \drupal_install_config_directories()
Creates the config directory and ensures it is operational.
See also
install_settings_form_submit()
update_prepare_d8_bootstrap()
2 calls to drupal_install_config_directories()
- SiteSettingsForm::submitForm in core/
lib/ Drupal/ Core/ Installer/ Form/ SiteSettingsForm.php - Form submission handler.
- UpdatePathTestBase::setUp in core/
modules/ system/ src/ Tests/ Update/ UpdatePathTestBase.php - Overrides WebTestBase::setUp() for update testing.
File
- core/
includes/ install.inc, line 482 - API functions for installing modules and themes.
Code
function drupal_install_config_directories() {
global $config_directories;
// Add a randomized config directory name to settings.php, unless it was
// manually defined in the existing already.
$settings = [];
$config_directories_hash = Crypt::randomBytesBase64(55);
if (empty($config_directories[CONFIG_SYNC_DIRECTORY])) {
$settings['config_directories'][CONFIG_SYNC_DIRECTORY] = (object) [
'value' => \Drupal::service('site.path') . '/files/config_' . $config_directories_hash . '/sync',
'required' => TRUE,
];
}
if (!empty($settings)) {
// Rewrite settings.php, which also sets the value as global variable.
drupal_rewrite_settings($settings);
}
// This should never fail, since if the config directory was specified in
// settings.php it will have already been created and verified earlier, and
// if it wasn't specified in settings.php, it is created here inside the
// public files directory, which has already been verified to be writable
// itself. But if it somehow fails anyway, the installation cannot proceed.
// Bail out using a similar error message as in system_requirements().
if (!install_ensure_config_directory(CONFIG_SYNC_DIRECTORY)) {
throw new Exception(t('The directory %directory could not be created or could not be made writable. To proceed with the installation, either create the directory and modify its permissions manually or ensure that the installer has the permissions to create it automatically. For more information, see the <a href=":handbook_url">online handbook</a>.', array(
'%directory' => config_get_config_directory(CONFIG_SYNC_DIRECTORY),
':handbook_url' => 'https://www.drupal.org/server-permissions',
)));
}
// Put a README.txt into the sync config directory. This is required so that
// they can later be added to git. Since this directory is auto-created, we
// have to write out the README rather than just adding it to the drupal core
// repo.
$text = 'This directory contains configuration to be imported into your Drupal site. To make this configuration active, visit admin/config/development/configuration/sync.' . ' For information about deploying configuration between servers, see https://www.drupal.org/documentation/administer/config';
file_put_contents(config_get_config_directory(CONFIG_SYNC_DIRECTORY) . '/README.txt', $text);
}