Installs a default configuration file into the active store.
Provide a generalised method to save a default configuration object for an already enabled module or theme as part of an update from Drupal 7 to Drupal 8's configuration management system.
string $type: The extension type; e.g., 'module' or 'theme'.
string $config_name: The configuration object name to retrieve.
boolean True on success, false if config file does not exist.
function update_7_to_8_install_default_config($type, $config_name) {
// Build the new configuration object.
$config = Drupal::config($config_name);
// Extract the extension namespace/owner from the configuration object name.
$name = strtok($config_name, '.');
// Load and set default configuration values.
$file = new FileStorage(drupal_get_path($type, $name) . '/config');
if (!$file
->exists($config_name)) {
return FALSE;
}
// Apply and save the default values.
$config
->setData($file
->read($config_name))
->save();
return TRUE;
}