You are here

function features_export_info in Features 7

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

Generate code friendly to the Drupal .info format from a structured array.

Parameters

$info: An array or single value to put in a module's .info file.

$parents: Array of parent keys (internal use only).

Return value

A code string ready to be written to a module's .info file.

2 calls to features_export_info()
features_detect_overrides in ./features.export.inc
Detect differences between DB and code components of a feature.
features_export_render in ./features.export.inc
Render feature export into an array representing its files.

File

./features.export.inc, line 398

Code

function features_export_info($info, $parents = array()) {
  $output = '';
  if (is_array($info)) {
    foreach ($info as $k => $v) {
      $child = $parents;
      $child[] = $k;
      $output .= features_export_info($v, $child);
    }
  }
  else {
    if (!empty($info) && count($parents)) {
      $line = array_shift($parents);
      foreach ($parents as $key) {
        $line .= is_numeric($key) ? "[]" : "[{$key}]";
      }
      $line .= " = {$info}\n";
      return $line;
    }
  }
  return $output;
}