You are here

protected function ConfigDiffer::normalize in Configuration Update Manager 8

Normalizes config for comparison.

Removes elements in the ignore list from the top level of configuration, and at each level of the array, removes empty arrays and sorts by array key, so that config from different storage can be compared meaningfully.

Parameters

array|null $config: Configuration array to normalize.

Return value

array Normalized configuration array.

See also

ConfigDiffer::format()

ConfigDiffer::$ignore

2 calls to ConfigDiffer::normalize()
ConfigDiffer::diff in src/ConfigDiffer.php
Calculates differences between config.
ConfigDiffer::same in src/ConfigDiffer.php
Decides if two configuration arrays are considered to be the same.

File

src/ConfigDiffer.php, line 79

Class

ConfigDiffer
Provides methods related to config differences.

Namespace

Drupal\config_update

Code

protected function normalize($config) {
  if (empty($config)) {
    return [];
  }

  // Remove "ignore" elements, only at the top level.
  foreach ($this->ignore as $element) {
    unset($config[$element]);
  }

  // Recursively normalize and return.
  return $this
    ->normalizeArray($config);
}