function update_7_to_8_install_default_config

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.

Parameters

string $type: The extension type; e.g., 'module' or 'theme'.

string $config_name: The configuration object name to retrieve.

Return value

boolean True on success, false if config file does not exist.

1 call to update_7_to_8_install_default_config()
system_update_8055 in drupal/core/modules/system/system.install
Move system theme settings from variables to config.

File

drupal/core/includes/update.inc, line 1430
Drupal database update API.

Code

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;
}