You are here

protected function ConfigInstaller::findPreExistingConfiguration in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Config/ConfigInstaller.php \Drupal\Core\Config\ConfigInstaller::findPreExistingConfiguration()

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.

1 call to ConfigInstaller::findPreExistingConfiguration()
ConfigInstaller::checkConfigurationToInstall in core/lib/Drupal/Core/Config/ConfigInstaller.php
Checks the configuration that will be installed for an extension.

File

core/lib/Drupal/Core/Config/ConfigInstaller.php, line 405
Contains \Drupal\Core\Config\ConfigInstaller.

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;
}