W3cubDocs

/Drupal 8

public function ConfigInstaller::checkConfigurationToInstall

public ConfigInstaller::checkConfigurationToInstall($type, $name)

Checks the configuration that will be installed for an extension.

Parameters

string $type: Type of extension to install.

string $name: Name of extension to install.

Throws

\Drupal\Core\Config\UnmetDependenciesException

\Drupal\Core\Config\PreExistingConfigException

Overrides ConfigInstallerInterface::checkConfigurationToInstall

File

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

Class

ConfigInstaller

Namespace

Drupal\Core\Config

Code

public function checkConfigurationToInstall($type, $name) {
  if ($this->isSyncing()) {
    // Configuration is assumed to already be checked by the config importer
    // validation events.
    return;
  }
  $config_install_path = $this->getDefaultConfigDirectory($type, $name);
  if (!is_dir($config_install_path)) {
    return;
  }

  $storage = new FileStorage($config_install_path, StorageInterface::DEFAULT_COLLECTION);

  $enabled_extensions = $this->getEnabledExtensions();
  // Add the extension that will be enabled to the list of enabled extensions.
  $enabled_extensions[] = $name;
  // Gets profile storages to search for overrides if necessary.
  $profile_storages = $this->getProfileStorages($name);

  // Check the dependencies of configuration provided by the module.
  $invalid_default_config = $this->findDefaultConfigWithUnmetDependencies($storage, $enabled_extensions, $profile_storages);
  if (!empty($invalid_default_config)) {
    throw UnmetDependenciesException::create($name, $invalid_default_config);
  }

  // Install profiles can not have config clashes. Configuration that
  // has the same name as a module's configuration will be used instead.
  if ($name != $this->drupalGetProfile()) {
    // Throw an exception if the module being installed contains configuration
    // that already exists. Additionally, can not continue installing more
    // modules because those may depend on the current module being installed.
    $existing_configuration = $this->findPreExistingConfiguration($storage);
    if (!empty($existing_configuration)) {
      throw PreExistingConfigException::create($name, $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::checkConfigurationToInstall/8.1.x