You are here

protected function KeyConfigOverrideAddForm::flattenConfigItemList in Key 8

Recursively create a flat array of configuration items.

Parameters

array $config_array: An array of configuration items.

string $prefix: A prefix to add to nested items.

int $level: The current level of nesting.

Return value

array The flattened array of configuration items.

1 call to KeyConfigOverrideAddForm::flattenConfigItemList()
KeyConfigOverrideAddForm::getConfigItems in src/Form/KeyConfigOverrideAddForm.php
Get the configuration items for a specified configuration name.

File

src/Form/KeyConfigOverrideAddForm.php, line 394

Class

KeyConfigOverrideAddForm
KeyConfigOverrideAddForm class.

Namespace

Drupal\key\Form

Code

protected function flattenConfigItemList(array $config_array, $prefix = '', $level = 0) {
  $config_items = [];

  // Define items to ignore.
  $ignore = [
    'uuid',
    '_core',
  ];
  foreach ($config_array as $key => $value) {
    if (in_array($key, $ignore) && $level == 0) {
      continue;
    }
    if (is_array($value) && $level < 5) {
      $config_items = array_merge($config_items, $this
        ->flattenConfigItemList($value, $prefix . $key . '.', $level + 1));
    }
    else {
      $config_items[] = $prefix . $key;
    }
  }
  return $config_items;
}