Commit 5b191447 authored by alexpott's avatar alexpott

Issue #2459971 by Gábor Hojtsy: The langcode key on configuration files is not...

Issue #2459971 by Gábor Hojtsy: The langcode key on configuration files is not explicit in configuration schema
parent f35996ad
......@@ -81,6 +81,14 @@ color_hex:
# Complex extended data types:
# Root of a configuration object.
config_object:
type: mapping
mapping:
langcode:
type: string
label: 'Language code'
# Mail text with subject and body parts.
mail:
type: mapping
......@@ -121,7 +129,7 @@ action_configuration_default:
type: string
theme_settings:
type: mapping
type: config_object
mapping:
favicon:
type: mapping
......@@ -183,12 +191,6 @@ theme_settings:
sequence:
type: theme_settings.third_party.[%key]
theme_breakpoints_default:
type: sequence
sequence:
type: string
label: 'Breakpoint value'
views_field_bulk_form:
type: views_field
label: 'Bulk operation'
......@@ -262,7 +264,7 @@ config_entity:
label: 'UUID'
langcode:
type: string
label: 'Default language'
label: 'Language code'
status:
type: boolean
label: 'Status'
......@@ -416,9 +418,6 @@ core.date_format.*:
pattern:
type: date_format
label: 'PHP date format'
langcode:
type: string
label: 'Default language'
# Generic field settings schemas.
......
core.extension:
type: mapping
type: config_object
label: 'Extension settings'
mapping:
module:
......
core.menu.static_menu_link_overrides:
type: mapping
type: config_object
label: 'Static menu link overrides'
mapping:
definitions:
......
......@@ -53,7 +53,7 @@ public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $co
if (!$typed_config->hasConfigSchema($config_name)) {
return FALSE;
}
$definition = $typed_config->getDefinition($config_name, TRUE, TRUE);
$definition = $typed_config->getDefinition($config_name);
$data_definition = $typed_config->buildDataDefinition($definition, $config_data);
$this->schema = $typed_config->create($data_definition, $config_data);
$errors = array();
......
......@@ -128,7 +128,7 @@ public function getStorage() {
*/
protected function getSchemaWrapper() {
if (!isset($this->schemaWrapper)) {
$definition = $this->typedConfigManager->getDefinition($this->name, TRUE, TRUE);
$definition = $this->typedConfigManager->getDefinition($this->name);
$data_definition = $this->typedConfigManager->buildDataDefinition($definition, $this->data);
$this->schemaWrapper = $this->typedConfigManager->create($data_definition, $this->data);
}
......
......@@ -72,7 +72,7 @@ public function __construct(StorageInterface $configStorage, StorageInterface $s
*/
public function get($name) {
$data = $this->configStorage->read($name);
$type_definition = $this->getDefinition($name, TRUE, TRUE);
$type_definition = $this->getDefinition($name);
$data_definition = $this->buildDataDefinition($type_definition, $data);
return $this->create($data_definition, $data);
}
......
......@@ -111,8 +111,8 @@ public function hasConfigSchema($name);
* Ignored with TypedConfigManagerInterface. Kept for compatibility with
* DiscoveryInterface.
* @param bool $is_config_name
* Set to TRUE if $plugin_id is a configuration name (as opposed to an
* internal configuration schema type).
* (deprecated) Set to TRUE if $plugin_id is a configuration name (as
* opposed to an internal configuration schema type).
*
* @return array
* A plugin definition array. If the given plugin id does not have typed
......
# Schema for the configuration files of the Action module.
action.settings:
type: mapping
type: config_object
label: 'Action settings'
mapping:
recursion_limit:
......
# Schema for the configuration files of the aggregator module.
aggregator.settings:
type: mapping
type: config_object
label: 'Aggregator settings'
mapping:
fetcher:
......
# Schema for the configuration files of the Aggregator Test module.
aggregator_test.settings:
type: mapping
type: config_object
label: 'Aggregator test settings'
mapping:
items:
......
# Schema for the configuration files of the book module.
book.settings:
type: mapping
type: config_object
label: 'Book settings'
mapping:
allowed_types:
......
color.theme.*:
type: mapping
type: config_object
label: 'Color theme settings'
mapping:
palette:
......
......@@ -61,6 +61,8 @@ function testSchemaMapping() {
$expected = array();
$expected['label'] = 'Schema test data';
$expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
$expected['mapping']['langcode']['type'] = 'string';
$expected['mapping']['langcode']['label'] = 'Language code';
$expected['mapping']['testitem'] = array('label' => 'Test item');
$expected['mapping']['testlist'] = array('label' => 'Test list');
$expected['type'] = 'config_schema_test.someschema';
......@@ -101,7 +103,7 @@ function testSchemaMapping() {
'type' => 'text',
);
$expected['mapping']['langcode'] = array(
'label' => 'Default language',
'label' => 'Language code',
'type' => 'string',
);
$expected['type'] = 'system.maintenance';
......@@ -114,6 +116,10 @@ function testSchemaMapping() {
$expected['label'] = 'Ignore test';
$expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
$expected['mapping']['langcode'] = array(
'type' => 'string',
'label' => 'Language code',
);
$expected['mapping']['label'] = array(
'label' => 'Label',
'type' => 'label',
......@@ -156,7 +162,7 @@ function testSchemaMapping() {
$expected['mapping']['uuid']['type'] = 'string';
$expected['mapping']['uuid']['label'] = 'UUID';
$expected['mapping']['langcode']['type'] = 'string';
$expected['mapping']['langcode']['label'] = 'Default language';
$expected['mapping']['langcode']['label'] = 'Language code';
$expected['mapping']['status']['type'] = 'boolean';
$expected['mapping']['status']['label'] = 'Status';
$expected['mapping']['dependencies']['type'] = 'config_dependencies';
......@@ -222,6 +228,8 @@ function testSchemaMapping() {
$expected = array();
$expected['label'] = 'Schema multiple filesytem marker test';
$expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
$expected['mapping']['langcode']['type'] = 'string';
$expected['mapping']['langcode']['label'] = 'Language code';
$expected['mapping']['testid']['type'] = 'string';
$expected['mapping']['testid']['label'] = 'ID';
$expected['mapping']['testdescription']['type'] = 'text';
......@@ -396,6 +404,8 @@ function testSchemaFallback() {
$expected['label'] = 'Schema wildcard fallback test';
$expected['class'] = '\Drupal\Core\Config\Schema\Mapping';
$expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition';
$expected['mapping']['langcode']['type'] = 'string';
$expected['mapping']['langcode']['label'] = 'Language code';
$expected['mapping']['testid']['type'] = 'string';
$expected['mapping']['testid']['label'] = 'ID';
$expected['mapping']['testdescription']['type'] = 'text';
......
config_collection_install_test.test:
type: mapping
type: config_object
label: 'Collection test'
mapping:
collection:
......
config_events_test.test:
type: mapping
type: config_object
label: 'Configuration events test'
mapping:
key:
......
# Schema for the configuration files of the Configuration Integration Test module.
config_integration_test.settings:
type: mapping
type: config_object
label: 'Configuration integration test settings'
mapping:
foo:
......
# Schema for the configuration files of the Configuration Schema Test module.
config_schema_test.someschema:
type: mapping
type: config_object
label: 'Schema test data'
mapping:
testitem:
......@@ -11,7 +11,7 @@ config_schema_test.someschema:
config_schema_test.someschema.with_parents:
label: 'Schema test data with parenting'
type: mapping
type: config_object
mapping:
one_level:
label: 'Parenting one level up'
......@@ -64,7 +64,7 @@ config_schema_test.someschema.with_parents.key_3:
type: string
config_schema_test.someschema.somemodule.*.*:
type: mapping
type: config_object
label: 'Schema multiple filesytem marker test'
mapping:
testid:
......@@ -75,7 +75,7 @@ config_schema_test.someschema.somemodule.*.*:
label: 'Description'
config_schema_test.wildcard_fallback.*:
type: mapping
type: config_object
label: 'Schema wildcard fallback test'
mapping:
testid:
......@@ -86,7 +86,7 @@ config_schema_test.wildcard_fallback.*:
label: 'Description'
config_schema_test.schema_data_types:
type: mapping
type: config_object
label: 'Config test schema'
mapping:
config_schema_test_integer:
......@@ -127,7 +127,7 @@ config_schema_test.schema_data_types:
config_schema_test.schema_in_install:
label: 'Schema test data with parenting'
type: mapping
type: config_object
mapping:
integer:
type: integer
......@@ -138,7 +138,7 @@ config_schema_test_integer:
label: 'Config test integer'
config_schema_test.ignore:
type: mapping
type: config_object
label: 'Ignore test'
mapping:
label:
......@@ -155,7 +155,7 @@ config_schema_test.ignore:
label: 'Weight'
config_schema_test.plugin_types:
type: mapping
type: config_object
mapping:
tests:
type: sequence
......
......@@ -56,7 +56,7 @@ config_test.query.*:
label: 'number'
config_test.types:
type: mapping
type: config_object
label: 'Configuration type'
mapping:
array:
......@@ -94,7 +94,7 @@ config_test.types:
label: 'String integer'
config_test.no_status.default:
type: mapping
type: config_object
label: 'Configuration no status default'
mapping:
id:
......@@ -105,7 +105,7 @@ config_test.no_status.default:
label: 'Label'
config_test.system:
type: mapping
type: config_object
label: 'Configuration system'
mapping:
foo:
......@@ -119,7 +119,7 @@ config_test.system:
label: '404'
config_test.new:
type: mapping
type: config_object
label: 'Configuration test'
mapping:
key:
......@@ -136,7 +136,7 @@ config_test.old:
type: config_test.new
config_test.foo:
type: mapping
type: config_object
label: 'Configuration test'
mapping:
value:
......
# Schema for the configuration files of the Configuration translation test module.
config_translation_test.content:
type: mapping
type: config_object
label: 'Content'
mapping:
id:
......@@ -10,9 +10,6 @@ config_translation_test.content:
label:
type: label
label: 'Label'
langcode:
type: string
label: 'Default language'
content:
type: text_format
label: 'Content'
......
......@@ -24,7 +24,7 @@ contact.form.*:
label: 'Weight'
contact.settings:
type: mapping
type: config_object
label: 'Contact settings'
mapping:
default_form:
......
# Schema for the configuration files of the dblog module.
dblog.settings:
type: mapping
type: config_object
label: 'Database logging settings'
mapping:
row_limit:
......
# Schema for configuration files of the Field module.
field.settings:
type: mapping
type: config_object
label: 'Field settings'
mapping:
purge_batch_size:
......
# Schema for configuration files of the Field UI module.
field_ui.settings:
type: mapping
type: config_object
label: 'Field UI settings'
mapping:
field_prefix:
......
# Schema for the configuration files of the File module.
file.settings:
type: mapping
type: config_object
label: 'File settings'
mapping:
description:
......
# Schema for the configuration files of the Filter module.
filter.settings:
type: mapping
type: config_object
label: 'Filter settings'
mapping:
fallback_format:
......@@ -35,9 +35,6 @@ filter.format.*:
label: 'Enabled filters'
sequence:
type: filter
langcode:
type: string
label: 'Default language'
dependencies:
type: config_dependencies
label: 'Dependencies'
......
# Schema for the configuration files of the Forum module.
forum.settings:
type: mapping
type: config_object
label: 'Forum settings'
mapping:
block:
......
......@@ -70,7 +70,7 @@ image.effect.image_scale_and_crop:
label: 'Image scale and crop'
image.settings:
type: mapping
type: config_object
mapping:
preview_image:
type: string
......
# Browsers use different language codes to refer to the same languages,
# these defaults handles the most common cases.
no: 'nb' # Norwegian
pt: 'pt-pt' # Portuguese
zh: 'zh-hans' # Default Chinese to simplified script
zh-tw: 'zh-hant' # Taiwan Chinese in traditional script
zh-hk: 'zh-hant' # Hong Kong Chinese in traditional script
zh-mo: 'zh-hant' # Macao Chinese in traditional script
zh-cht: 'zh-hant' # traditional Chinese
zh-cn: 'zh-hans' # PRC Mainland Chinese in simplified script
zh-sg: 'zh-hans' # Singapore Chinese in simplified script
zh-chs: 'zh-hans' # simplified Chinese
map:
no: 'nb' # Norwegian
pt: 'pt-pt' # Portuguese
zh: 'zh-hans' # Default Chinese to simplified script
zh-tw: 'zh-hant' # Taiwan Chinese in traditional script
zh-hk: 'zh-hant' # Hong Kong Chinese in traditional script
zh-mo: 'zh-hant' # Macao Chinese in traditional script
zh-cht: 'zh-hant' # traditional Chinese
zh-cn: 'zh-hans' # PRC Mainland Chinese in simplified script
zh-sg: 'zh-hans' # Singapore Chinese in simplified script
zh-chs: 'zh-hans' # simplified Chinese
......@@ -18,7 +18,7 @@ language_type_negotiation:
label: Weight
language.types:
type: mapping
type: config_object
label: 'Language types'
mapping:
all:
......@@ -41,7 +41,7 @@ language.types:
label: 'Language negotiation per type setting'
language.negotiation:
type: mapping
type: config_object
label: 'Language detection methods'
mapping:
session:
......@@ -75,11 +75,14 @@ language.negotiation:
label: 'Selected language'
language.mappings:
type: sequence
type: config_object
label: 'Language mapping'
sequence:
type: string
label: 'Language'
mapping:
map:
type: sequence
sequence:
type: string
label: 'Language'
language.entity.*:
type: config_entity
......
......@@ -448,7 +448,7 @@ function language_get_browser_drupal_langcode_mappings() {
if ($config->isNew()) {
return array();
}
return $config->get();
return $config->get('map');
}
/**
......
......@@ -71,7 +71,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $browser_
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.mappings')
->clear($this->browserLangcode)
->clear('map.' . $this->browserLangcode)
->save();
$args = array(
......
......@@ -180,7 +180,7 @@ public function submitForm(array &$form, FormStateInterface $form_state) {
$mappings = $form_state->get('mappings');
if (!empty($mappings)) {
$config = $this->config('language.mappings');
$config->setData($mappings);
$config->setData(['map' => $mappings]);
$config->save();
}
......@@ -198,7 +198,7 @@ protected function language_get_browser_drupal_langcode_mappings() {
if ($config->isNew()) {
return array();
}
return $config->get();
return $config->get('map');
}
}
......@@ -39,7 +39,7 @@ public function getLangcode(Request $request = NULL) {
if ($this->languageManager && $request && $request->server->get('HTTP_ACCEPT_LANGUAGE')) {
$http_accept_language = $request->server->get('HTTP_ACCEPT_LANGUAGE');
$langcodes = array_keys($this->languageManager->getLanguages());
$mappings = $this->config->get('language.mappings')->get();
$mappings = $this->config->get('language.mappings')->get('map');
$langcode = UserAgent::getBestMatchingLangcode($http_accept_language, $langcodes, $mappings);
}
......
# Schema for the configuration files of the Locale module.
locale.settings:
type: mapping
type: config_object
label: 'Translate interface settings'
mapping:
cache_strings:
......
......@@ -134,7 +134,7 @@ public function getTranslatableDefaultConfig($name) {
if ($this->isSupported($name)) {
// Create typed configuration wrapper based on install storage data.
$data = $this->installStorageRead($name);
$type_definition = $this->typedConfigManager->getDefinition($name, TRUE, TRUE);
$type_definition = $this->typedConfigManager->getDefinition($name);
$data_definition = $this->typedConfigManager->buildDataDefinition($type_definition, $data);
$typed_config = $this->typedConfigManager->create($data_definition, $data);
if ($typed_config instanceof TraversableTypedDataInterface) {
......
# Schema for the configuration files of the Locale Test module.
locale_test.no_translation:
type: mapping
type: config_object
label: 'No traslation settings'
mapping:
test:
......@@ -9,11 +9,9 @@ locale_test.no_translation:
label: 'Test'
# See \Drupal\locale\Tests\LocaleConfigSubscriberTest
translatable: true
langcode:
type: string
locale_test.translation:
type: mapping
type: config_object
label: 'translation settings'
mapping:
test:
......@@ -21,5 +19,3 @@ locale_test.translation:
label: 'Test'
# See \Drupal\locale\Tests\LocaleConfigSubscriberTest
translatable: true
langcode:
type: string
......@@ -331,7 +331,7 @@ migrate_entity_constant:
label: 'Parent'
langcode:
type: string
label: 'Type'
label: 'Language code'
third_party_settings:
type: sequence
label: 'Settings'
......
# Schema for the configuration files of the node module.
node.settings:
type: mapping
type: config_object
label: 'Node settings'
mapping:
use_admin_theme:
......
# Schema for the configuration files of the REST module.
rest.settings:
type: mapping
type: config_object
label: 'REST settings'
mapping:
resources:
......
# Schema for the configuration files of the search module.
search.settings:
type: mapping
type: config_object
label: 'Search settings'
mapping:
and_or_limit:
......
# Schema for the configuration files of the Simpletest module.
simpletest.settings:
type: mapping
type: config_object
label: 'Testing'
mapping:
clear_results:
......
# Schema for the configuration files of the statistics module.
statistics.settings:
type: mapping
type: config_object
label: 'Statistics settings'
mapping:
access_log:
......
# Schema for the configuration files of the syslog module.
syslog.settings:
type: mapping
type: config_object
label: 'Syslog settings'
mapping:
identity:
......
# Schema for the configuration files of the System module.