You are here

protected function Updater::getFlatKeys in Update helper 8

Same name and namespace in other branches
  1. 2.x src/Updater.php \Drupal\update_helper\Updater::getFlatKeys()

Get flatten array keys as list of paths.

Example: $nestedArray = [ 'a' => [ 'b' => [ 'c' => 'c1', ], 'bb' => 'bb1' ], 'aa' => 'aa1' ]

Result: [ ['a', 'b', 'c'], ['a', 'bb'] ['aa'] ]

Parameters

array $nested_array: Array with nested keys.

Return value

array List of flattened keys.

1 call to Updater::getFlatKeys()
Updater::applyConfigActions in src/Updater.php
Apply configuration changes on configuration array.

File

src/Updater.php, line 316

Class

Updater
Helper class to update configuration.

Namespace

Drupal\update_helper

Code

protected function getFlatKeys(array $nested_array) {
  $keys = [];
  foreach ($nested_array as $key => $value) {
    if (is_array($value) && !empty($value)) {
      $list_of_sub_keys = $this
        ->getFlatKeys($value);
      foreach ($list_of_sub_keys as $subKeys) {
        $keys[] = array_merge([
          $key,
        ], $subKeys);
      }
    }
    else {
      $keys[] = [
        $key,
      ];
    }
  }
  return $keys;
}