public function ConfigDiffTransformer::transform in Update helper 8
Same name and namespace in other branches
- 2.x src/ConfigDiffTransformer.php \Drupal\update_helper\ConfigDiffTransformer::transform()
File
- src/
ConfigDiffTransformer.php, line 33
Class
- ConfigDiffTransformer
- Config transformer for configuration diffing.
Namespace
Drupal\update_helperCode
public function transform($config, $prefix = '') {
$lines = [];
$associative_config = array_keys($config) !== range(0, count($config) - 1);
foreach ($config as $key => $value) {
if (!$associative_config) {
$key = '-';
}
$section_prefix = $prefix ? $prefix . $this->hierarchyPrefix . $key : $key;
if (is_array($value) && !empty($value)) {
$lines[] = $section_prefix;
$new_lines = $this
->transform($value, $section_prefix);
foreach ($new_lines as $line) {
$lines[] = $line;
}
}
else {
$lines[] = $section_prefix . $this->valuePrefix . $this
->stringifyValue($value);
}
}
return $lines;
}