You are here

function features_var_export in Features 6

Same name and namespace in other branches
  1. 7.2 features.export.inc \features_var_export()
  2. 7 features.export.inc \features_var_export()

Export var function -- from Views.

15 calls to features_var_export()
content_features_export_render in includes/features.content.inc
Implementation of hook_features_export_render().
features_detect_overrides in ./features.export.inc
Detect differences between DB and code components of a feature.
features_get_signature in ./features.export.inc
Wrapper around features_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.
features_translatables_export in ./features.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.
fieldgroup_features_export_render in includes/features.fieldgroup.inc
Implementation of hook_features_export_render().

... See full list

File

./features.export.inc, line 446

Code

function features_var_export($var, $prefix = '', $init = TRUE) {
  if (is_object($var)) {
    $output = method_exists($var, 'export') ? $var
      ->export() : features_var_export((array) $var);
  }
  else {
    if (is_array($var)) {
      if (empty($var)) {
        $output = 'array()';
      }
      else {
        $output = "array(\n";
        foreach ($var as $key => $value) {
          $output .= "  '{$key}' => " . features_var_export($value, '  ', FALSE) . ",\n";
        }
        $output .= ')';
      }
    }
    else {
      if (is_bool($var)) {
        $output = $var ? 'TRUE' : 'FALSE';
      }
      else {
        if (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);
        }
        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;
}