- $map = [];
- foreach ($config_values as $key => $value) {
- $map[] = [$key, $value];
- }
- // Also allow to pass in no argument.
- $map[] = ['', $config_values];
+ // Define a closure over the $config_values, which will be used as a
+ // returnCallback below. This function will mimic
+ // \Drupal\Core\Config\Config::get and allow using dotted keys.
+ $config_get = function ($key = '') use ($config_values) {
+ // Allow to pass in no argument.
+ if (empty($key)) {
+ return $config_values;
+ }
+ // See if we have the key as is.
+ if (isset($config_values[$key])) {
+ return $config_values[$key];
+ }
+ $parts = explode('.', $key);
+ $value = NestedArray::getValue($config_values, $parts, $key_exists);
+ return $key_exists ? $value : NULL;
+ };