function config_install_default_config

Installs the default configuration of a given extension.

Parameters

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

string $name: The name of the module or theme to install default configuration for.

7 calls to config_install_default_config()
ConfigImportTest::setUp in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigImportTest.php
Sets up Drupal unit test environment.
ConfigOverrideTest::setUp in drupal/core/modules/config/lib/Drupal/config/Tests/ConfigOverrideTest.php
Sets up Drupal unit test environment.
drupal_install_system in drupal/core/includes/install.inc
Installs the system module.
FilterUnitTest::setUp in drupal/core/modules/filter/lib/Drupal/filter/Tests/FilterUnitTest.php
Sets up Drupal unit test environment.
module_enable in drupal/core/includes/module.inc
Enables or installs a given list of modules.

... See full list

File

drupal/core/includes/config.inc, line 26
This is the API for configuration storage.

Code

function config_install_default_config($type, $name) {
  $config_dir = drupal_get_path($type, $name) . '/config';
  if (is_dir($config_dir)) {
    $source_storage = new FileStorage($config_dir);
    $target_storage = drupal_container()
      ->get('config.storage');

    // If this module defines any ConfigEntity types, then create a manifest file
    // for each of them with a listing of the objects it maintains.
    foreach (config_get_module_config_entities($name) as $entity_type => $entity_info) {
      $manifest_config = config('manifest.' . $entity_info['config_prefix']);
      $manifest_data = array();
      foreach ($source_storage
        ->listAll($entity_info['config_prefix']) as $config_name) {
        list(, , $id) = explode('.', $config_name);
        $manifest_data[$id]['name'] = $config_name;
      }
      $manifest_config
        ->setData($manifest_data)
        ->save();
    }
    $config_changes = array(
      'delete' => array(),
      'create' => array(),
      'change' => array(),
    );
    $config_changes['create'] = $source_storage
      ->listAll();
    if (empty($config_changes['create'])) {
      return;
    }
    $remaining_changes = config_import_invoke_owner($config_changes, $source_storage, $target_storage);
    config_sync_changes($remaining_changes, $source_storage, $target_storage);
  }
}