diff --git a/core/includes/config.inc b/core/includes/config.inc index 7e1cfed..00ed39c 100644 --- a/core/includes/config.inc +++ b/core/includes/config.inc @@ -47,41 +47,6 @@ 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); } } @@ -361,3 +326,18 @@ function config_get_entity_type_by_name($name) { function config_typed() { return drupal_container()->get('config.typed'); } + +/* + * Returns the typed config manager service. + * + * Use the typed data manager service for creating typed configuration objects. + * + * @see Drupal\Core\TypedData\TypedDataManager::create() + * + * @return Drupal\Core\TypedData\TypedConfigManager + */ +function config_schema() { + return drupal_container()->get('config.schema'); +} + + diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaConfigManager.php b/core/lib/Drupal/Core/Config/Schema/SchemaConfigManager.php new file mode 100644 index 0000000..8fa0c0c --- /dev/null +++ b/core/lib/Drupal/Core/Config/Schema/SchemaConfigManager.php @@ -0,0 +1,16 @@ +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 schema configuration storage. + $container + ->register('config.schema.storage', 'Drupal\Core\Config\Schema\SchemaStorage'); + + // Register the schema configuration data manager. + $container->register('config.schema', 'Drupal\Core\Config\Schema\SchemaConfigManager') + ->addArgument(new Reference('config.schema.storage')); // Register the service for the default database connection. $container->register('database', 'Drupal\Core\Database\Connection') diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php index 93a7b55..32bc2b5 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigSchemaTest.php @@ -41,7 +41,7 @@ public function setUp() { */ function testSchemaMapping() { // Simple case, straight metadata. - $definition = config_typed()->getDefinition('system.maintenance'); + $definition = config_schema()->getDefinition('system.maintenance'); $expected = array(); $expected['label'] = 'Maintenance mode'; $expected['class'] = '\Drupal\Core\Config\Schema\Mapping'; @@ -56,7 +56,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for system.maintenance'); // More complex case, generic type. Metadata for image style. - $definition = config_typed()->getDefinition('image.style.large'); + $definition = config_schema()->getDefinition('image.style.large'); $expected = array(); $expected['label'] = 'Image style'; $expected['class'] = '\Drupal\Core\Config\Schema\Mapping'; @@ -72,7 +72,7 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for image.style.large'); // More complex, type based on a complex one. - $definition = config_typed()->getDefinition('image.effect.image_scale'); + $definition = config_schema()->getDefinition('image.effect.image_scale'); // This should be the schema for image.effect.image_scale. $expected = array(); $expected['label'] = 'Image scale';