diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 9fc14b2..ace69e9 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -22,11 +22,11 @@ class ConfigInstaller implements ConfigInstallerInterface { protected $configFactory; /** - * The active configuration storage. + * The active configuration storages, keyed by collection. * - * @var \Drupal\Core\Config\StorageInterface + * @var \Drupal\Core\Config\StorageInterface[] */ - protected $activeStorage; + protected $activeStorages; /** * The typed configuration manager. @@ -79,7 +79,7 @@ class ConfigInstaller implements ConfigInstallerInterface { */ public function __construct(ConfigFactoryInterface $config_factory, StorageInterface $active_storage, TypedConfigManagerInterface $typed_config, ConfigManagerInterface $config_manager, EventDispatcherInterface $event_dispatcher) { $this->configFactory = $config_factory; - $this->activeStorage = $active_storage; + $this->activeStorages[$active_storage->getCollectionName()] = $active_storage; $this->typedConfig = $typed_config; $this->configManager = $config_manager; $this->eventDispatcher = $event_dispatcher; @@ -191,7 +191,7 @@ protected function createConfiguration($collection, array $config_to_install) { } // Remove configuration that already exists in the active storage. - $config_to_install = array_diff($config_to_install, $this->getActiveStorage($collection)->listAll()); + $config_to_install = array_diff($config_to_install, $this->getActiveStorages($collection)->listAll()); foreach ($config_to_install as $name) { // Allow config factory overriders to use a custom configuration object if @@ -201,7 +201,7 @@ protected function createConfiguration($collection, array $config_to_install) { $new_config = $overrider->createConfigObject($name, $collection); } else { - $new_config = new Config($name, $this->getActiveStorage($collection), $this->eventDispatcher, $this->typedConfig); + $new_config = new Config($name, $this->getActiveStorages($collection), $this->eventDispatcher, $this->typedConfig); } if ($data[$name] !== FALSE) { $new_config->setData($data[$name]); @@ -222,7 +222,7 @@ protected function createConfiguration($collection, array $config_to_install) { ->getStorage($entity_type); // It is possible that secondary writes can occur during configuration // creation. Updates of such configuration are allowed. - if ($this->getActiveStorage($collection)->exists($name)) { + if ($this->getActiveStorages($collection)->exists($name)) { $id = $entity_storage->getIDFromConfigName($name, $entity_storage->getEntityType()->getConfigPrefix()); $entity = $entity_storage->load($id); $entity = $entity_storage->updateFromStorageRecord($entity, $new_config->get()); @@ -291,7 +291,7 @@ public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECT // Default to using the ExtensionInstallStorage which searches extension's // config directories for default configuration. Only include the profile // configuration during Drupal installation. - $this->sourceStorage = new ExtensionInstallStorage($this->activeStorage, InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, drupal_installation_attempted()); + $this->sourceStorage = new ExtensionInstallStorage($this->getActiveStorages(StorageInterface::DEFAULT_COLLECTION), InstallStorage::CONFIG_INSTALL_DIRECTORY, $collection, drupal_installation_attempted()); } if ($this->sourceStorage->getCollectionName() != $collection) { $this->sourceStorage = $this->sourceStorage->createCollection($collection); @@ -309,11 +309,11 @@ public function getSourceStorage($collection = StorageInterface::DEFAULT_COLLECT * @return \Drupal\Core\Config\StorageInterface * The configuration storage that provides the default configuration. */ - protected function getActiveStorage($collection = StorageInterface::DEFAULT_COLLECTION) { - if ($this->activeStorage->getCollectionName() != $collection) { - $this->activeStorage = $this->activeStorage->createCollection($collection); + protected function getActiveStorages($collection = StorageInterface::DEFAULT_COLLECTION) { + if (!isset($this->activeStorages[$collection])) { + $this->activeStorages[$collection] = reset($this->activeStorages)->createCollection($collection); } - return $this->activeStorage; + return $this->activeStorages[$collection]; } /** @@ -348,7 +348,7 @@ public function findPreExistingConfiguration($type, $name) { $enabled_extensions[] = $name; foreach ($collection_info->getCollectionNames(TRUE) as $collection) { $config_to_install = $this->listDefaultConfigCollection($collection, $type, $name, $enabled_extensions); - $active_storage = $this->getActiveStorage($collection); + $active_storage = $this->getActiveStorages($collection); foreach ($config_to_install as $config_name) { if ($active_storage->exists($config_name)) { $existing_configuration[$collection][] = $config_name;