W3cubDocs

/Drupal 8

public function ConfigInstaller::installCollectionDefaultConfig

public ConfigInstaller::installCollectionDefaultConfig($collection)

Installs all default configuration in the specified collection.

The function is useful if the site needs to respond to an event that has just created another collection and we need to check all the installed extensions for any matching configuration. For example, if a language has just been created.

Parameters

string $collection: The configuration collection.

Overrides ConfigInstallerInterface::installCollectionDefaultConfig

File

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

Class

ConfigInstaller

Namespace

Drupal\Core\Config

Code

public function installCollectionDefaultConfig($collection) {
  $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, $this->drupalInstallationAttempted());
  // Only install configuration for enabled extensions.
  $enabled_extensions = $this->getEnabledExtensions();
  $config_to_install = array_filter($storage->listAll(), function($config_name) use ($enabled_extensions) {
    $provider = Unicode::substr($config_name, 0, strpos($config_name, '.'));
    return in_array($provider, $enabled_extensions);
  });
  if (!empty($config_to_install)) {
    $this->createConfiguration($collection, $storage->readMultiple($config_to_install));
    // Reset all the static caches and list caches.
    $this->configFactory->reset();
  }
}

© 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::installCollectionDefaultConfig/8.1.x