function SettingsEditor::exportSettingsToPhp
Same name in other branches
- 10 core/lib/Drupal/Core/Site/SettingsEditor.php \Drupal\Core\Site\SettingsEditor::exportSettingsToPhp()
Recursively exports one or more settings to a valid PHP string.
Parameters
array|object $variable: The container for variable values.
string $variable_name: Name of variable.
Return value
string A string containing valid PHP code of the variable suitable for placing into settings.php.
1 call to SettingsEditor::exportSettingsToPhp()
- SettingsEditor::rewrite in core/
lib/ Drupal/ Core/ Site/ SettingsEditor.php - Replaces values in settings.php with values in the submitted array.
File
-
core/
lib/ Drupal/ Core/ Site/ SettingsEditor.php, line 267
Class
- SettingsEditor
- Generates settings.php files for Drupal installations.
Namespace
Drupal\Core\SiteCode
private static function exportSettingsToPhp(array|object $variable, string $variable_name) : string {
$return = '';
if (is_object($variable)) {
if (!empty($variable->required)) {
$return .= self::exportSingleSettingToPhp($variable, "{$variable_name} = ", "\n");
}
}
else {
foreach ($variable as $k => $v) {
$return .= self::exportSettingsToPhp($v, $variable_name . "['" . $k . "']");
}
}
return $return;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.