You are here

function configuration_var_export in Configuration Management 7

Export var function -- from Views.

11 calls to configuration_var_export()
configuration_diff in ./configuration.admin.inc
Page callback to display the differences between what's in code and what is in the db.
configuration_get_signature in ./configuration.export.inc
Wrapper around configuration_get_[storage] to return an md5hash of a normalized defaults/normal object array. Can be used to compare normal/default states of a module's component.
configuration_translatables_export in ./configuration.export.inc
Helper function to return an array of t()'d translatables strings. Useful for providing a separate array of translatables with your export so that string extractors like potx can detect them.
field_configuration_export_render in includes/configuration.field.inc
Implements hook_configuration_export_render().
filter_configuration_export_render in includes/configuration.filter.inc
Implements hook_configuration_export_render().

... See full list

File

./configuration.export.inc, line 347

Code

function configuration_var_export($var, $prefix = '', $init = TRUE) {
  if (is_object($var)) {
    $output = method_exists($var, 'export') ? $var
      ->export() : configuration_var_export((array) $var);
  }
  elseif (is_array($var)) {
    if (empty($var)) {
      $output = 'array()';
    }
    else {
      $output = "array(\n";
      foreach ($var as $key => $value) {

        // Using normal var_export on the key to ensure correct quoting.
        $output .= "  " . var_export($key, TRUE) . " => " . configuration_var_export($value, '  ', FALSE) . ",\n";
      }
      $output .= ')';
    }
  }
  elseif (is_bool($var)) {
    $output = $var ? '1' : '0';
  }
  elseif (is_string($var) && strpos($var, "\n") !== FALSE) {

    // Replace line breaks in strings with a token for replacement
    // at the very end. This protects whitespace in strings from
    // unintentional indentation.
    $var = str_replace("\n", "***BREAK***", $var);
    $output = var_export($var, TRUE);
  }
  elseif (is_numeric($var)) {
    $output = is_int($var) ? var_export((int) $var, TRUE) : var_export((double) $var, TRUE);
  }
  else {
    $output = var_export($var, TRUE);
  }
  if ($prefix) {
    $output = str_replace("\n", "\n{$prefix}", $output);
  }
  if ($init) {
    $output = str_replace("***BREAK***", "\n", $output);
  }
  return $output;
}