A tool to merge together separate configurations for Drupal 8 sites.
Taking a primary configuration this tool will analyse the configuration available and perform the following actions.
- If the configuration exists in the primary and not in the secondary then leave it alone and add it to the primary config split blacklist.
- If the configuration exists in both sites and there is no difference between the two sites then the configuration is placed into a default configuration area.
- If the configuration exists in both sites and that configuration is different then add this configuration to the configuration split grey list for both sites and make a copy in the default configuration.
- If the configuration exists in both sites, contains a single difference, and that difference is just the uuid, then copy the primary configuration to the default configuration area and delete the sibling configuration file. This step also generates output in the form of a update hook that can be used to update the uuid for all sites.
The tool doesn't understand Drupal configuration, just the YAML structure that it contains.
Just install the tool using composer into your Drupal codebase.
composer require --dev hashbangcode/config_split_merge
composer remove --dev hashbangcode/config_split_merge
You first need to ensure that the configuration split config files have been created for the configurations you want to merge. You don't need to install the configuration splits on all sites, but the config files need to exist.
The tool needs minimal setup, you just need to ensure that the configuration directory structure looks something like this.
/config/default
/config/default/config_split.config_split.parent.yml
/config/default/config_split.config_split.child1.yml
/config/default/config_split.config_split.child2.yml
/config/parent
/config/child1
/config/child2
NOTE: This tool will alter the config directories in-situ, i.e. it will permanently alter your config directories. Make sure you have adequate backups before hand!
Run the tool by passing the parent and child directories that need analysis.
./vendor/bin/config_split_merge drupal:config_split_merge parent child
./vendor/bin/config_split_merge drupal:config_split_merge parent child1,child2
./vendor/bin/config_split_merge drupal:config_split_merge parent child --config=sync/config
<?php
/**
* Fix the uuid information on certain configs.
*/
function my_module_update_8001() {
$fieldChanges = [
'node.type.landing_page' => '2034e796-4d2c-43f0-9135-1afc93052380',
];
foreach ($fieldChanges as $field => $uuid) {
$config = \Drupal::service('config.factory')->getEditable($field);
$config->set('uuid', $uuid)->save();
}
}
Once the tool has run you will need to import and export the configuration to ensure all sites are set up correctly.
The tool takes two arguments.
parent - The parent directory that will be treated as the primary site.
children - The children directories that will be treated as the sub-sites. Either a single value or a comma separated list.
The following flags can be passed to the tool