diff --git a/core/includes/config.inc b/core/includes/config.inc index 3e22534..8ef5ee5 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -24,34 +24,53 @@ * The name of the module or theme to install default configuration for. */ 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 ($type == 'module') { + $list = module_list(); + } + else { + $list = array_keys(list_themes()); + } + $config_changes = array('delete' => array(), 'change' => array()); + $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(); - } + // Determine config entity types implemented by the installed extension. + $config_entity_types = config_get_module_config_entities($name); - $config_changes = array( - 'delete' => array(), - 'create' => array(), - 'change' => array(), - ); - $config_changes['create'] = $source_storage->listAll(); + foreach ($list as $extension) { + if (!is_dir($config_dir = drupal_get_path($type, $extension) . '/config')) { + continue; + } + $source_storage = new FileStorage($config_dir); + $config_changes['create'] = array(); + // Other extensions may only provide default configuration for configuration + // entities. Static extension settings must not be overridden. + foreach ($config_entity_types as $entity_type => $entity_info) { + $config_changes['create'] = $source_storage->listAll($entity_info['config_prefix'] . '.'); + } + // For the extension being installed, list all configuration objects, and + // ensure that a default configuration of the extension takes precedence (in + // case an identical name appears in another extension). + if ($extension == $name) { + $config_changes['create'] = array_merge($config_changes['create'], $source_storage->listAll($extension . '.')); + } if (empty($config_changes['create'])) { - return; + continue; } $remaining_changes = config_import_invoke_owner($config_changes, $source_storage, $target_storage); - config_sync_changes($remaining_changes, $source_storage, $target_storage); + if ($extension == $name) { + config_sync_changes($remaining_changes, $source_storage, $target_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']); + $id_index = count(explode('.', $entity_info['config_prefix'])); + foreach ($target_storage->listAll($entity_info['config_prefix'] . '.') as $config_name) { + $parts = explode('.', $config_name); + $manifest_config->set($parts[$id_index] . '.name', $config_name); + } + $manifest_config->save(); } }