function drupal_rewrite_settings
Same name in other branches
- 7.x includes/install.inc \drupal_rewrite_settings()
- 9 core/includes/install.inc \drupal_rewrite_settings()
- 8.9.x core/includes/install.inc \drupal_rewrite_settings()
Replaces values in settings.php with values in the submitted array.
This function replaces values in place if possible, even for multidimensional arrays. This way the old settings do not linger, overridden and also the doxygen on a value remains where it should be.
Parameters
$settings: An array of settings that need to be updated. Multidimensional arrays are dumped up to a stdClass object. The object can have value, required and comment properties.
$settings['settings']['config_sync_directory'] = (object) [
'value' => 'config_hash/sync',
'required' => TRUE,
];
gets dumped as:
$settings['config_sync_directory'] = 'config_hash/sync';
Deprecated
in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. Note $settings_file argument becomes required and the first argument of the method.
See also
https://www.drupal.org/node/3244583
\Drupal\Core\Site\SettingsEditor::rewrite()
1 call to drupal_rewrite_settings()
- LegacySettingsRewriteTest::testDrupalRewriteSettings in core/
tests/ Drupal/ KernelTests/ Core/ Site/ LegacySettingsRewriteTest.php - Tests the drupal_rewrite_settings() function.
File
-
core/
includes/ install.inc, line 275
Code
function drupal_rewrite_settings($settings = [], $settings_file = NULL) {
@trigger_error(__FUNCTION__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use SettingsEditor::rewrite() instead. The order of the arguments has also changed: $settings_file is now required and is the first argument of the method. See https://www.drupal.org/node/3244583', E_USER_DEPRECATED);
SettingsEditor::rewrite($settings_file ?? \Drupal::getContainer()->getParameter('site.path') . '/settings.php', $settings);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.