W3cubDocs

/Drupal 8

protected function ConfigInstaller::findPreExistingConfiguration

protected ConfigInstaller::findPreExistingConfiguration(StorageInterface $storage)

Finds pre-existing configuration objects for the provided extension.

Extensions can not be installed if configuration objects exist in the active storage with the same names. This can happen in a number of ways, commonly:

  • if a user has created configuration with the same name as that provided by the extension.
  • if the extension provides default configuration that does not depend on it and the extension has been uninstalled and is about to the reinstalled.

Return value

array Array of configuration object names that already exist keyed by collection.

File

core/lib/Drupal/Core/Config/ConfigInstaller.php, line 418

Class

ConfigInstaller

Namespace

Drupal\Core\Config

Code

protected function findPreExistingConfiguration(StorageInterface $storage) {
  $existing_configuration = array();
  // Gather information about all the supported collections.
  $collection_info = $this->configManager->getConfigCollectionInfo();

  foreach ($collection_info->getCollectionNames() as $collection) {
    $config_to_create = array_keys($this->getConfigToCreate($storage, $collection));
    $active_storage = $this->getActiveStorages($collection);
    foreach ($config_to_create as $config_name) {
      if ($active_storage->exists($config_name)) {
        $existing_configuration[$collection][] = $config_name;
      }
    }
  }
  return $existing_configuration;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Config!ConfigInstaller.php/function/ConfigInstaller::findPreExistingConfiguration/8.1.x