protected function ReversibleConfigDiffer::format in Update helper 8
Same name and namespace in other branches
- 2.x src/ReversibleConfigDiffer.php \Drupal\update_helper\ReversibleConfigDiffer::format()
Formats config for showing differences.
To compute differences, we need to separate the config into lines and use line-by-line differencer. The obvious way to split into lines is:
explode("\n", Yaml::encode($config));
But this would highlight meaningless differences due to the often different order of config files, and also loses the indentation and context of the config hierarchy when differences are computed, making the difference difficult to interpret.
So, what we do instead is to take the YAML hierarchy and format it so that the hierarchy is shown on each line. So, if you're in element $config['foo']['bar'] and the value is 'value', you will see 'foo::bar : value'.
Parameters
array $config: Config array to format. Normalize it first if you want to do diffs.
string $prefix: (optional) When called recursively, the prefix to put on each line. Omit when initially calling this function.
Return value
string[] Array of config lines formatted so that a line-by-line diff will show the context in each line, and meaningful differences will be computed.
Overrides ConfigDiffer::format
See also
ConfigDiffer::$hierarchyPrefix
ConfigDiffer::$valuePrefix
File
- src/
ReversibleConfigDiffer.php, line 87
Class
- ReversibleConfigDiffer
- Overwrite of config updater differ.
Namespace
Drupal\update_helperCode
protected function format(array $config, $prefix = '') {
return $this->configDiffTransformer
->transform($config, $prefix);
}