only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -161,13 +161,17 @@ public function installDefaultConfig($type, $name) { if (is_dir($optional_install_path)) { // Install any optional config the module provides. $storage = new FileStorage($optional_install_path, StorageInterface::DEFAULT_COLLECTION); - $this->installOptionalConfig($storage, ''); + foreach ($collection_info->getCollectionNames() as $collection) { + $this->installOptionalConfig($storage, '', $collection); + } } // Install any optional configuration entities whose dependencies can now // be met. This searches all the installed modules config/optional // directories. $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, FALSE, $this->installProfile); - $this->installOptionalConfig($storage, [$type => $name]); + foreach ($collection_info->getCollectionNames() as $collection) { + $this->installOptionalConfig($storage, [$type => $name], $collection); + } } // Reset all the static caches and list caches. @@ -177,22 +181,26 @@ public function installDefaultConfig($type, $name) { /** * {@inheritdoc} */ - public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = []) { + public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = [], $collection = StorageInterface::DEFAULT_COLLECTION) { $profile = $this->drupalGetProfile(); $enabled_extensions = $this->getEnabledExtensions(); $existing_config = $this->getActiveStorages()->listAll(); + if (!empty($storage) && $storage->getCollectionName() != $collection) { + $storage = $storage->createCollection($collection); + } + // Create the storages to read configuration from. if (!$storage) { // Search the install profile's optional configuration too. - $storage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, StorageInterface::DEFAULT_COLLECTION, TRUE, $this->installProfile); + $storage = new ExtensionInstallStorage($this->getActiveStorages($collection), InstallStorage::CONFIG_OPTIONAL_DIRECTORY, $collection, TRUE, $this->installProfile); // The extension install storage ensures that overrides are used. $profile_storage = NULL; } elseif (!empty($profile)) { // Creates a profile storage to search for overrides. $profile_install_path = $this->extensionPathResolver->getPath('module', $profile) . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; - $profile_storage = new FileStorage($profile_install_path, StorageInterface::DEFAULT_COLLECTION); + $profile_storage = new FileStorage($profile_install_path, $collection); } else { // Profile has not been set yet. For example during the first steps of the @@ -211,7 +219,10 @@ public function installOptionalConfig(StorageInterface $storage = NULL, $depende // Filter the list of configuration to only include configuration that // should be created. - $list = array_filter($list, function ($config_name) use ($existing_config) { + $list = array_filter($list, function ($config_name) use ($existing_config, $collection) { + if ($collection != StorageInterface::DEFAULT_COLLECTION) { + return TRUE; + } // Only list configuration that: // - does not already exist // - is a configuration entity (this also excludes config that has an @@ -257,7 +268,7 @@ public function installOptionalConfig(StorageInterface $storage = NULL, $depende // Create the optional configuration if there is any left after filtering. if (!empty($config_to_create)) { - $this->createConfiguration(StorageInterface::DEFAULT_COLLECTION, $config_to_create); + $this->createConfiguration($collection, $config_to_create); } } only in patch2: unchanged: --- a/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php +++ b/core/lib/Drupal/Core/Config/ConfigInstallerInterface.php @@ -50,8 +50,10 @@ public function installDefaultConfig($type, $name); * this dependency. The format is dependency type as the key ('module', * 'theme', or 'config') and the dependency name as the value * ('book', 'olivero', 'views.view.frontpage'). + * @param string $collection + * (optional) The configuration collection. */ - public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = []); + public function installOptionalConfig(StorageInterface $storage = NULL, $dependency = [], $collection = StorageInterface::DEFAULT_COLLECTION); /** * Installs all default configuration in the specified collection. only in patch2: unchanged: --- a/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php @@ -79,9 +79,9 @@ public function installDefaultConfig($type, $name) * {@inheritdoc} */ public function installOptionalConfig(?\Drupal\Core\Config\StorageInterface $storage = NULL, $dependency = array ( - )) + ), $collection = '') { - return $this->lazyLoadItself()->installOptionalConfig($storage, $dependency); + return $this->lazyLoadItself()->installOptionalConfig($storage, $dependency, $collection); } /**