diff --git a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php index 43be83e..17dfb13 100644 --- a/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php +++ b/core/lib/Drupal/Core/Config/ConfigCollectionInfo.php @@ -41,6 +41,9 @@ public function addCollection($collection, ConfigFactoryOverrideInterface $overr if ($collection == StorageInterface::DEFAULT_COLLECTION) { throw new \InvalidArgumentException('Can not add the default collection to the ConfigCollectionInfo object'); } + if ($collection == StorageInterface::ORIGINAL_COPY_COLLECTION) { + throw new \InvalidArgumentException('Can not add the original copy collection to the ConfigCollectionInfo object'); + } $this->collections[$collection] = $override_service; } diff --git a/core/lib/Drupal/Core/Config/ConfigInstaller.php b/core/lib/Drupal/Core/Config/ConfigInstaller.php index 1c7993b..792316b 100644 --- a/core/lib/Drupal/Core/Config/ConfigInstaller.php +++ b/core/lib/Drupal/Core/Config/ConfigInstaller.php @@ -203,9 +203,16 @@ protected function createConfiguration($collection, array $config_to_install) { } else { $new_config = new Config($name, $this->getActiveStorages($collection), $this->eventDispatcher, $this->typedConfig); + // Create a copy of the original configuration for later reference. + if ($collection == StorageInterface::DEFAULT_COLLECTION) { + $config_copy = new Config($name, $this->getActiveStorages(StorageInterface::ORIGINAL_COPY_COLLECTION), $this->eventDispatcher, $this->typedConfig); + } } if ($data[$name] !== FALSE) { $new_config->setData($data[$name]); + if (isset($config_copy)) { + $config_copy->setData($data[$name])->save(); + } } if ($config_entity_support && $entity_type = $this->configManager->getEntityTypeIdByName($name)) { diff --git a/core/lib/Drupal/Core/Config/StorageInterface.php b/core/lib/Drupal/Core/Config/StorageInterface.php index f6145b8..b9ec918 100644 --- a/core/lib/Drupal/Core/Config/StorageInterface.php +++ b/core/lib/Drupal/Core/Config/StorageInterface.php @@ -21,6 +21,11 @@ const DEFAULT_COLLECTION = ''; /** + * Collection for storing copies of original configuration. + */ + const ORIGINAL_COPY_COLLECTION = 'originalcopy'; + + /** * Returns whether a configuration object exists. * * @param string $name