You are here

protected function ConfigDiffer::normalizeArray in Configuration Update Manager 8

Recursively sorts an array by key, and removes empty arrays.

Parameters

array $array: An array to normalize.

Return value

array An array that is sorted by key, at each level of the array, with empty arrays removed.

1 call to ConfigDiffer::normalizeArray()
ConfigDiffer::normalize in src/ConfigDiffer.php
Normalizes config for comparison.

File

src/ConfigDiffer.php, line 103

Class

ConfigDiffer
Provides methods related to config differences.

Namespace

Drupal\config_update

Code

protected function normalizeArray(array $array) {
  foreach ($array as $key => $value) {
    if (is_array($value)) {
      $new = $this
        ->normalizeArray($value);
      if (count($new)) {
        $array[$key] = $new;
      }
      else {
        unset($array[$key]);
      }
    }
  }
  ksort($array);
  return $array;
}