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

8.0.x
Alex Pott 2015-03-31 10:40:13 +01:00
parent f35996ad3a
commit 5b19144783
54 changed files with 121 additions and 140 deletions

View File

@ -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.

View File

@ -1,5 +1,5 @@
core.extension:
type: mapping
type: config_object
label: 'Extension settings'
mapping:
module:

View File

@ -1,5 +1,5 @@
core.menu.static_menu_link_overrides:
type: mapping
type: config_object
label: 'Static menu link overrides'
mapping:
definitions:

View File

@ -53,7 +53,7 @@ trait SchemaCheckTrait {
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();

View File

@ -128,7 +128,7 @@ abstract class StorableConfigBase extends ConfigBase {
*/
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);
}

View File

@ -72,7 +72,7 @@ class TypedConfigManager extends TypedDataManager implements TypedConfigManagerI
*/
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);
}

View File

@ -111,8 +111,8 @@ Interface TypedConfigManagerInterface extends PluginManagerInterface, CachedDisc
* 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

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Action module.
action.settings:
type: mapping
type: config_object
label: 'Action settings'
mapping:
recursion_limit:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the aggregator module.
aggregator.settings:
type: mapping
type: config_object
label: 'Aggregator settings'
mapping:
fetcher:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Aggregator Test module.
aggregator_test.settings:
type: mapping
type: config_object
label: 'Aggregator test settings'
mapping:
items:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the book module.
book.settings:
type: mapping
type: config_object
label: 'Book settings'
mapping:
allowed_types:

View File

@ -1,5 +1,5 @@
color.theme.*:
type: mapping
type: config_object
label: 'Color theme settings'
mapping:
palette:

View File

@ -61,6 +61,8 @@ class ConfigSchemaTest extends KernelTestBase {
$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 @@ class ConfigSchemaTest extends KernelTestBase {
'type' => 'text',
);
$expected['mapping']['langcode'] = array(
'label' => 'Default language',
'label' => 'Language code',
'type' => 'string',
);
$expected['type'] = 'system.maintenance';
@ -114,6 +116,10 @@ class ConfigSchemaTest extends KernelTestBase {
$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 @@ class ConfigSchemaTest extends KernelTestBase {
$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 @@ class ConfigSchemaTest extends KernelTestBase {
$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 @@ class ConfigSchemaTest extends KernelTestBase {
$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';

View File

@ -1,5 +1,5 @@
config_collection_install_test.test:
type: mapping
type: config_object
label: 'Collection test'
mapping:
collection:

View File

@ -1,5 +1,5 @@
config_events_test.test:
type: mapping
type: config_object
label: 'Configuration events test'
mapping:
key:

View File

@ -1,7 +1,7 @@
# 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:

View File

@ -1,7 +1,7 @@
# 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

View File

@ -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:

View File

@ -1,7 +1,7 @@
# 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'

View File

@ -24,7 +24,7 @@ contact.form.*:
label: 'Weight'
contact.settings:
type: mapping
type: config_object
label: 'Contact settings'
mapping:
default_form:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the dblog module.
dblog.settings:
type: mapping
type: config_object
label: 'Database logging settings'
mapping:
row_limit:

View File

@ -1,7 +1,7 @@
# Schema for configuration files of the Field module.
field.settings:
type: mapping
type: config_object
label: 'Field settings'
mapping:
purge_batch_size:

View File

@ -1,7 +1,7 @@
# Schema for configuration files of the Field UI module.
field_ui.settings:
type: mapping
type: config_object
label: 'Field UI settings'
mapping:
field_prefix:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the File module.
file.settings:
type: mapping
type: config_object
label: 'File settings'
mapping:
description:

View File

@ -1,7 +1,7 @@
# 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'

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Forum module.
forum.settings:
type: mapping
type: config_object
label: 'Forum settings'
mapping:
block:

View File

@ -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

View File

@ -1,12 +1,13 @@
# 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

View File

@ -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

View File

@ -448,7 +448,7 @@ function language_get_browser_drupal_langcode_mappings() {
if ($config->isNew()) {
return array();
}
return $config->get();
return $config->get('map');
}
/**

View File

@ -71,7 +71,7 @@ class NegotiationBrowserDeleteForm extends ConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->config('language.mappings')
->clear($this->browserLangcode)
->clear('map.' . $this->browserLangcode)
->save();
$args = array(

View File

@ -180,7 +180,7 @@ class NegotiationBrowserForm extends ConfigFormBase {
$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 @@ class NegotiationBrowserForm extends ConfigFormBase {
if ($config->isNew()) {
return array();
}
return $config->get();
return $config->get('map');
}
}

View File

@ -39,7 +39,7 @@ class LanguageNegotiationBrowser extends LanguageNegotiationMethodBase {
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);
}

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Locale module.
locale.settings:
type: mapping
type: config_object
label: 'Translate interface settings'
mapping:
cache_strings:

View File

@ -134,7 +134,7 @@ class LocaleConfigManager {
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) {

View File

@ -1,7 +1,7 @@
# 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

View File

@ -331,7 +331,7 @@ migrate_entity_constant:
label: 'Parent'
langcode:
type: string
label: 'Type'
label: 'Language code'
third_party_settings:
type: sequence
label: 'Settings'

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the node module.
node.settings:
type: mapping
type: config_object
label: 'Node settings'
mapping:
use_admin_theme:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the REST module.
rest.settings:
type: mapping
type: config_object
label: 'REST settings'
mapping:
resources:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the search module.
search.settings:
type: mapping
type: config_object
label: 'Search settings'
mapping:
and_or_limit:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Simpletest module.
simpletest.settings:
type: mapping
type: config_object
label: 'Testing'
mapping:
clear_results:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the statistics module.
statistics.settings:
type: mapping
type: config_object
label: 'Statistics settings'
mapping:
access_log:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the syslog module.
syslog.settings:
type: mapping
type: config_object
label: 'Syslog settings'
mapping:
identity:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the System module.
system.site:
type: mapping
type: config_object
label: 'Site information'
mapping:
uuid:
@ -35,9 +35,6 @@ system.site:
weight_select_max:
type: integer
label: 'Weight element maximum value'
langcode:
type: string
label: 'Language code'
default_langcode:
type: string
label: 'Site default language code'
@ -46,18 +43,15 @@ system.site:
label: 'Notification email address'
system.maintenance:
type: mapping
type: config_object
label: 'Maintenance mode'
mapping:
message:
type: text
label: 'Message to display when in maintenance mode'
langcode:
type: string
label: 'Default language'
system.authorize:
type: mapping
type: config_object
label: 'Authorize settings'
mapping:
filetransfer_default:
@ -65,7 +59,7 @@ system.authorize:
label: 'Default file transfer protocol'
system.cron:
type: mapping
type: config_object
label: 'Cron settings'
mapping:
threshold:
@ -83,7 +77,7 @@ system.cron:
label: 'Requirements error period'
system.date:
type: mapping
type: config_object
label: 'Date settings'
mapping:
first_day:
@ -96,9 +90,6 @@ system.date:
default:
type: string
label: 'Default country'
langcode:
type: string
label: 'Default language'
timezone:
type: mapping
label: 'Time zone settings'
@ -121,7 +112,7 @@ system.date:
label: 'Remind users at login if their time zone is not set'
system.diff:
type: mapping
type: config_object
label: 'Diff settings'
mapping:
context:
@ -136,7 +127,7 @@ system.diff:
label: 'Number of trailing lines in a diff'
system.filter:
type: mapping
type: config_object
label: 'Filter settings'
mapping:
protocols:
@ -147,7 +138,7 @@ system.filter:
label: 'Protocol'
system.logging:
type: mapping
type: config_object
label: 'Logging settings'
mapping:
error_level:
@ -155,7 +146,7 @@ system.logging:
label: 'Error messages to display'
system.performance:
type: mapping
type: config_object
label: 'Performance settings'
mapping:
cache:
@ -220,7 +211,7 @@ system.performance:
label: 'Stale file threshold'
system.rss:
type: mapping
type: config_object
label: 'Feed settings'
mapping:
channel:
@ -240,12 +231,9 @@ system.rss:
view_mode:
type: string
label: 'Feed content'
langcode:
type: string
label: 'Default language'
system.theme:
type: mapping
type: config_object
label: 'Theme settings'
mapping:
admin:
@ -292,7 +280,7 @@ system.action.*:
type: action.configuration.[%parent.plugin]
system.file:
type: mapping
type: config_object
label: 'File system'
mapping:
allow_insecure_uploads:
@ -313,7 +301,7 @@ system.file:
label: 'Maximum age for temporary files'
system.image:
type: mapping
type: config_object
label: 'Image settings'
mapping:
toolkit:
@ -321,7 +309,7 @@ system.image:
label: 'Toolkit'
system.image.gd:
type: mapping
type: config_object
label: 'Image settings'
mapping:
jpeg_quality:
@ -329,7 +317,7 @@ system.image.gd:
label: 'JPEG quality'
system.mail:
type: mapping
type: config_object
label: 'Mail system'
mapping:
interface:

View File

@ -1,5 +1,5 @@
form_test.object:
type: mapping
type: config_object
label: 'Test form'
mapping:
bananas:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Update Script Test module.
update_script_test.settings:
type: mapping
type: config_object
label: ''
mapping:
requirement_type:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Taxonomy module.
taxonomy.settings:
type: mapping
type: config_object
label: 'Taxonomy settings'
mapping:
maintain_index_table:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the text module.
text.settings:
type: mapping
type: config_object
label: 'Text settings'
mapping:
default_summary_length:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the tracker module.
tracker.settings:
type: mapping
type: config_object
label: 'Tracker settings'
mapping:
cron_index_limit:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Update module.
update.settings:
type: mapping
type: config_object
label: 'Update settings'
mapping:
check:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Update Test module.
update_test.settings:
type: mapping
type: config_object
label: 'Update test settings'
mapping:
system_info:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the User module.
user.settings:
type: mapping
type: config_object
label: 'User settings'
mapping:
anonymous:
@ -50,12 +50,9 @@ user.settings:
password_strength:
type: boolean
label: 'Enable password strength indicator'
langcode:
type: string
label: 'Default language'
user.mail:
type: mapping
type: config_object
label: 'Email settings'
mapping:
cancel_confirm:
@ -85,12 +82,9 @@ user.mail:
status_canceled:
type: mail
label: 'Account cancelled'
langcode:
type: string
label: 'Default language'
user.flood:
type: mapping
type: config_object
label: 'User flood settings'
mapping:
uid_only:

View File

@ -1,7 +1,7 @@
# Schema for the configuration files of the Views module.
views.settings:
type: mapping
type: config_object
label: 'Views settings'
mapping:
display_extenders:

View File

@ -3,7 +3,3 @@
stark.settings:
type: theme_settings
label: 'Stark settings'
stark.breakpoints:
type: theme_breakpoints_default
label: 'Stark breakpoints'