function SettingsEditor::exportSingleSettingToPhp

Same name in other branches
  1. 10 core/lib/Drupal/Core/Site/SettingsEditor.php \Drupal\Core\Site\SettingsEditor::exportSingleSettingToPhp()

Exports the value of a value property and adds the comment if it exists.

Parameters

object $variable: A stdClass object with at least a value property.

string $prefix: A string to prepend to the variable's value.

string $suffix: A string to append to the variable's value.

Return value

string A string containing valid PHP code of the variable suitable for placing into settings.php.

2 calls to SettingsEditor::exportSingleSettingToPhp()
SettingsEditor::exportSettingsToPhp in core/lib/Drupal/Core/Site/SettingsEditor.php
Recursively exports one or more settings to a valid PHP string.
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 296

Class

SettingsEditor
Generates settings.php files for Drupal installations.

Namespace

Drupal\Core\Site

Code

private static function exportSingleSettingToPhp(object $variable, string $prefix = '', string $suffix = '') : string {
    $return = $prefix . var_export($variable->value, TRUE) . ';';
    if (!empty($variable->comment)) {
        $return .= ' // ' . $variable->comment;
    }
    $return .= $suffix;
    return $return;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.