You are here

function configuration_export_info in Configuration Management 7

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.

File

./configuration.export.inc, line 279

Code

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