diff --git a/core/includes/config.inc b/core/includes/config.inc index b4a0666..7e1cfed 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -4,6 +4,7 @@ use Drupal\Core\Config\FileStorage; use Drupal\Core\Config\NullStorage; use Drupal\Core\Config\StorageInterface; +use Drupal\Core\Config\Schema\SchemaStorage; /** * @file @@ -46,6 +47,41 @@ function config_install_default_config($type, $name) { } $remaining_changes = config_import_invoke_owner($config_changes, $source_storage, $target_storage); config_sync_changes($remaining_changes, $source_storage, $target_storage); + config_install_default_schema($type, $name); + } +} + +/** + * Installs the default configuration of a given extension. + * + * @param string $type + * The extension type; e.g., 'module' or 'theme'. + * @param string $name + * The name of the module or theme to install default configuration for. + */ +function config_install_default_schema($type, $name) { +/* // If this module defines any ConfigEntity types then create an empty + // manifest file for each of them. + foreach (config_get_module_config_entities($name) as $entity_info) { + config('manifest.' . $entity_info['config_prefix'])->save(); + }*/ + + $config_dir = drupal_get_path($type, $name) . '/config'; + if (is_dir($config_dir)) { + $source_storage = new SchemaStorage($config_dir); + $target_storage = drupal_container()->get('config.storage'); + + $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); } } @@ -240,6 +276,7 @@ function config_import() { * @param Drupal\Core\Config\StorageInterface $target_storage * The storage to synchronize configuration to. * + * @return array * @todo Add support for other extension types; e.g., themes etc. */ function config_import_invoke_owner(array $config_changes, StorageInterface $source_storage, StorageInterface $target_storage) { diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index 035f282..244c7cc 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -61,10 +61,18 @@ public function build(ContainerBuilder $container) { ->register('config.storage.staging', 'Drupal\Core\Config\FileStorage') ->addArgument(config_get_config_directory(CONFIG_STAGING_DIRECTORY)); + // Register schema configuration storage. + $container + ->register('config.schema.storage', 'Drupal\Core\Config\Schema\SchemaStorage'); + $container + ->register('config.schema', 'Drupal\Core\Config\Schema\SchemaDiscovery') + ->addArgument(new Reference('config.schema.storage')); + // Register the typed configuration data manager. $container->register('config.typed', 'Drupal\Core\Config\TypedConfigManager') ->addArgument(new Reference('config.storage')); + // Register the service for the default database connection. $container->register('database', 'Drupal\Core\Database\Connection') ->setFactoryClass('Drupal\Core\Database\Database')