function PreExistingConfigException::flattenConfigObjects

Same name in other branches
  1. 9 core/lib/Drupal/Core/Config/PreExistingConfigException.php \Drupal\Core\Config\PreExistingConfigException::flattenConfigObjects()
  2. 8.9.x core/lib/Drupal/Core/Config/PreExistingConfigException.php \Drupal\Core\Config\PreExistingConfigException::flattenConfigObjects()
  3. 10 core/lib/Drupal/Core/Config/PreExistingConfigException.php \Drupal\Core\Config\PreExistingConfigException::flattenConfigObjects()

Flattens the config object array to a single dimensional list.

Parameters

array $config_objects: A list of configuration objects that already exist in active configuration, keyed by config collection.

Return value

array A list of configuration objects that have been prefixed with their collection.

1 call to PreExistingConfigException::flattenConfigObjects()
PreExistingConfigException::create in core/lib/Drupal/Core/Config/PreExistingConfigException.php
Creates an exception for an extension and a list of configuration objects.

File

core/lib/Drupal/Core/Config/PreExistingConfigException.php, line 82

Class

PreExistingConfigException
An exception thrown if configuration with the same name already exists.

Namespace

Drupal\Core\Config

Code

public static function flattenConfigObjects(array $config_objects) {
    $flat_config_objects = [];
    foreach ($config_objects as $collection => $config_names) {
        $config_names = array_map(function ($config_name) use ($collection) {
            if ($collection != StorageInterface::DEFAULT_COLLECTION) {
                $config_name = str_replace('.', DIRECTORY_SEPARATOR, $collection) . DIRECTORY_SEPARATOR . $config_name;
            }
            return $config_name;
        }, $config_names);
        $flat_config_objects[] = $config_names;
    }
    return array_merge(...$flat_config_objects);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.