Commit 28e35f65 authored by alexpott's avatar alexpott

Issue #2414539 by webflo, vijaycs85: Simplify schema definition for sequence

parent 9defbd4f
......@@ -118,7 +118,7 @@ action_configuration_default:
type: sequence
label: 'Action configuration'
sequence:
- type: string
type: string
theme_settings:
type: mapping
......@@ -181,13 +181,13 @@ theme_settings:
type: sequence
label: 'Third party settings'
sequence:
- type: theme_settings.third_party.[%key]
type: theme_settings.third_party.[%key]
theme_breakpoints_default:
type: sequence
sequence:
- type: string
label: 'Breakpoint value'
type: string
label: 'Breakpoint value'
views_field_bulk_form:
type: views_field
......@@ -203,8 +203,8 @@ views_field_bulk_form:
type: sequence
label: 'Available actions'
sequence:
- type: string
label: 'Action'
type: string
label: 'Action'
# Array of routes with route_name and route_params keys.
route:
......@@ -218,8 +218,8 @@ route:
type: sequence
label: 'Route Params'
sequence:
- type: string
label: 'Param'
type: string
label: 'Param'
# Config dependencies.
config_dependencies_base:
......@@ -229,22 +229,22 @@ config_dependencies_base:
type: sequence
label: 'Configuration entity dependencies'
sequence:
- type: string
type: string
content:
type: sequence
label: 'Content entity dependencies'
sequence:
- type: string
type: string
module:
type: sequence
label: 'Module dependencies'
sequence:
- type: string
type: string
theme:
type: sequence
label: 'Theme dependencies'
sequence:
- type: string
type: string
config_dependencies:
type: config_dependencies_base
......@@ -273,7 +273,7 @@ config_entity:
type: sequence
label: 'Third party settings'
sequence:
- type: '[%parent.%parent.%type].third_party.[%key]'
type: '[%parent.%parent.%type].third_party.[%key]'
block_settings:
type: mapping
......@@ -299,8 +299,8 @@ block_settings:
type: sequence
label: 'Vary by context'
sequence:
- type: string
label: 'Context'
type: string
label: 'Context'
status:
type: boolean
label: 'Status'
......@@ -331,7 +331,7 @@ condition.plugin:
type: sequence
label: 'Context assignments'
sequence:
- type: string
type: string
display_variant.plugin:
type: mapping
......@@ -391,8 +391,8 @@ field_config_base:
type: sequence
label: 'Default values'
sequence:
- type: field.value.[%parent.%parent.field_type]
label: 'Default value'
type: field.value.[%parent.%parent.field_type]
label: 'Default value'
default_value_callback:
type: string
label: 'Default value callback'
......@@ -610,8 +610,8 @@ field.field_settings.email:
type: mapping
label: 'Email settings'
sequence:
- type: string
label: 'Setting'
type: string
label: 'Setting'
field.value.email:
type: mapping
......
......@@ -55,32 +55,32 @@ core.entity_view_display.*.*.*:
type: sequence
label: 'Field formatters'
sequence:
- type: mapping
label: 'Field formatter'
mapping:
type:
type: string
label: 'Format type machine name'
weight:
type: integer
label: 'Weight'
label:
type: string
label: 'Label setting machine name'
settings:
type: field.formatter.settings.[%parent.type]
label: 'Settings'
third_party_settings:
type: sequence
label: 'Third party settings'
sequence:
- type: field.formatter.third_party.[%key]
type: mapping
label: 'Field formatter'
mapping:
type:
type: string
label: 'Format type machine name'
weight:
type: integer
label: 'Weight'
label:
type: string
label: 'Label setting machine name'
settings:
type: field.formatter.settings.[%parent.type]
label: 'Settings'
third_party_settings:
type: sequence
label: 'Third party settings'
sequence:
type: field.formatter.third_party.[%key]
hidden:
type: sequence
label: 'Field display setting'
sequence:
- type: boolean
label: 'Value'
type: boolean
label: 'Value'
# Overview configuration information for form mode displays.
core.entity_form_display.*.*.*:
......@@ -106,29 +106,29 @@ core.entity_form_display.*.*.*:
type: sequence
label: 'Field widgets'
sequence:
- type: mapping
label: 'Field widget'
mapping:
type:
type: string
label: 'Widget type machine name'
weight:
type: integer
label: 'Weight'
settings:
type: field.widget.settings.[%parent.type]
label: 'Settings'
third_party_settings:
type: sequence
label: 'Third party settings'
sequence:
- type: field.widget.third_party.[%key]
type: mapping
label: 'Field widget'
mapping:
type:
type: string
label: 'Widget type machine name'
weight:
type: integer
label: 'Weight'
settings:
type: field.widget.settings.[%parent.type]
label: 'Settings'
third_party_settings:
type: sequence
label: 'Third party settings'
sequence:
type: field.widget.third_party.[%key]
hidden:
type: sequence
label: 'Hidden'
sequence:
- type: boolean
label: 'Component'
type: boolean
label: 'Component'
# Default schema for entity display field with undefined type.
field.formatter.settings.*:
......
......@@ -6,11 +6,11 @@ core.extension:
type: sequence
label: 'Enabled modules'
sequence:
- type: integer
label: 'Weight'
type: integer
label: 'Weight'
theme:
type: sequence
label: 'Installed themes'
sequence:
- type: integer
label: 'Weight'
type: integer
label: 'Weight'
......@@ -6,21 +6,21 @@ core.menu.static_menu_link_overrides:
type: sequence
label: Definitions
sequence:
- type: mapping
label: Definition
mapping:
menu_name:
type: string
label: 'Menu name'
parent:
type: string
label: 'Parent'
weight:
type: integer
label: 'Weight'
expanded:
type: boolean
label: 'Expanded'
enabled:
type: boolean
label: 'Enabled'
type: mapping
label: Definition
mapping:
menu_name:
type: string
label: 'Menu name'
parent:
type: string
label: 'Parent'
weight:
type: integer
label: 'Weight'
expanded:
type: boolean
label: 'Expanded'
enabled:
type: boolean
label: 'Enabled'
......@@ -23,7 +23,14 @@ class Sequence extends ArrayElement {
*/
protected function getElementDefinition($key) {
$value = isset($this->value[$key]) ? $this->value[$key] : NULL;
$definition = isset($this->definition['sequence'][0]) ? $this->definition['sequence'][0] : array();
// @todo: Remove BC layer for sequence with hyphen in front. https://www.drupal.org/node/2444979
$definition = array();
if (isset($this->definition['sequence'][0])) {
$definition = $this->definition['sequence'][0];
}
elseif ($this->definition['sequence']) {
$definition = $this->definition['sequence'];
}
return $this->buildDataDefinition($definition, $value, $key);
}
......
......@@ -14,8 +14,8 @@ aggregator.settings:
type: sequence
label: 'Processors'
sequence:
- type: string
label: 'Processor'
type: string
label: 'Processor'
items:
type: mapping
label: 'Items'
......
......@@ -28,8 +28,8 @@ block.block.*:
type: sequence
label: 'Visibility Conditions'
sequence:
- type: condition.plugin.[id]
label: 'Visibility Condition'
type: condition.plugin.[id]
label: 'Visibility Condition'
block.settings.*:
type: block_settings
......@@ -8,8 +8,8 @@ book.settings:
type: sequence
label: 'Content types allowed in book outlines'
sequence:
- type: string
label: 'Content type'
type: string
label: 'Content type'
block:
type: mapping
label: 'Block'
......
......@@ -12,26 +12,26 @@ editor.settings.ckeditor:
type: sequence
label: 'Rows'
sequence:
- type: sequence
label: 'Button groups'
sequence:
- type: mapping
label: 'Button group'
mapping:
name:
type: string
label: 'Button group name'
items:
type: sequence
label: 'Buttons'
sequence:
- type: string
label: 'Button'
type: sequence
label: 'Button groups'
sequence:
type: mapping
label: 'Button group'
mapping:
name:
type: string
label: 'Button group name'
items:
type: sequence
label: 'Buttons'
sequence:
type: string
label: 'Button'
plugins:
type: sequence
label: 'Plugins'
sequence:
- type: ckeditor.plugin.[%key]
type: ckeditor.plugin.[%key]
# Plugin \Drupal\ckeditor\Plugin\ckeditor\plugin\StylesCombo
ckeditor.plugin.stylescombo:
......
......@@ -6,15 +6,15 @@ color.theme.*:
type: sequence
label: 'Palette settings'
sequence:
- type: color_hex
type: color_hex
logo:
type: path
label: 'Logo path'
stylesheets:
type: sequence
sequence:
- type: path
type: path
files:
type: sequence
sequence:
- type: path
type: path
......@@ -28,8 +28,8 @@ action.configuration.comment_unpublish_by_keyword_action:
type: sequence
label: 'Keywords'
sequence:
- type: string
label: 'Keyword'
type: string
label: 'Keyword'
action.configuration.comment_unpublish_action:
type: action_configuration_default
......
......@@ -165,14 +165,14 @@ function testSchemaMapping() {
$expected['mapping']['label']['type'] = 'label';
$expected['mapping']['label']['label'] = 'Label';
$expected['mapping']['effects']['type'] = 'sequence';
$expected['mapping']['effects']['sequence'][0]['type'] = 'mapping';
$expected['mapping']['effects']['sequence'][0]['mapping']['id']['type'] = 'string';
$expected['mapping']['effects']['sequence'][0]['mapping']['data']['type'] = 'image.effect.[%parent.id]';
$expected['mapping']['effects']['sequence'][0]['mapping']['weight']['type'] = 'integer';
$expected['mapping']['effects']['sequence'][0]['mapping']['uuid']['type'] = 'string';
$expected['mapping']['effects']['sequence']['type'] = 'mapping';
$expected['mapping']['effects']['sequence']['mapping']['id']['type'] = 'string';
$expected['mapping']['effects']['sequence']['mapping']['data']['type'] = 'image.effect.[%parent.id]';
$expected['mapping']['effects']['sequence']['mapping']['weight']['type'] = 'integer';
$expected['mapping']['effects']['sequence']['mapping']['uuid']['type'] = 'string';
$expected['mapping']['third_party_settings']['type'] = 'sequence';
$expected['mapping']['third_party_settings']['label'] = 'Third party settings';
$expected['mapping']['third_party_settings']['sequence'][0]['type'] = '[%parent.%parent.%type].third_party.[%key]';
$expected['mapping']['third_party_settings']['sequence']['type'] = '[%parent.%parent.%type].third_party.[%key]';
$expected['type'] = 'image.style.*';
$this->assertEqual($definition, $expected);
......@@ -343,6 +343,7 @@ public function testConfigSaveWithSchema() {
'float' => '3.14',
'null_float' => '',
'sequence' => array (1, 0, 1),
'sequence_bc' => array(1, 0, 1),
// Not in schema and therefore should be left untouched.
'not_present_in_schema' => TRUE,
// Test a custom type.
......@@ -365,6 +366,7 @@ public function testConfigSaveWithSchema() {
'float' => 3.14,
'null_float' => NULL,
'sequence' => array (TRUE, FALSE, TRUE),
'sequence_bc' => array(TRUE, FALSE, TRUE),
'not_present_in_schema' => TRUE,
'config_schema_test_integer' => 1,
'config_schema_test_integer_empty_string' => NULL,
......
......@@ -117,6 +117,10 @@ config_schema_test.schema_data_types:
string:
type: string
sequence:
type: sequence
sequence:
type: boolean
sequence_bc:
type: sequence
sequence:
- type: boolean
......@@ -156,16 +160,16 @@ config_schema_test.plugin_types:
tests:
type: sequence
sequence:
- type: test.plugin_types.[plugin_id]
type: test.plugin_types.[plugin_id]
test_with_parents:
type: sequence
sequence:
- type: mapping
mapping:
plugin_id:
type: string
settings:
type: test_with_parents.plugin_types.[%parent.plugin_id]
type: mapping
mapping:
plugin_id:
type: string
settings:
type: test_with_parents.plugin_types.[%parent.plugin_id]
test.plugin_types:
type: mapping
......
......@@ -40,11 +40,11 @@ config_test.query.*:
type: sequence
label: 'Array level 1'
sequence:
- type: sequence
label: 'Array level 2'
sequence:
- type: integer
label: 'Value'
type: sequence
label: 'Array level 2'
sequence:
type: integer
label: 'Value'
number:
type: integer
label: 'number'
......@@ -57,8 +57,8 @@ config_test.types:
type: sequence
label: 'Array'
sequence:
- type: string
label: 'Item'
type: string
label: 'Item'
boolean:
type: boolean
label: 'Boolean'
......
......@@ -20,5 +20,5 @@ config_translation_test.content:
type: sequence
label: 'Animals'
sequence:
- type: label
type: label
......@@ -14,8 +14,8 @@ contact.form.*:
type: sequence
label: 'Recipients'
sequence:
- type: email
label: 'Email address'
type: email
label: 'Email address'
reply:
type: text
label: 'Auto-reply'
......
......@@ -8,8 +8,8 @@ field.field.*.*.*.third_party.content_translation:
type: sequence
label: 'Field properties for which to synchronize translations'
sequence:
- type: string
label: 'Field column for which to synchronize translations'
type: string
label: 'Field column for which to synchronize translations'
language.content_settings.*.*.third_party.content_translation:
type: mapping
......
......@@ -8,8 +8,8 @@ views.field.contextual_links:
type: sequence
label: 'Fields'
sequence:
- type: string
label: 'Link'
type: string
label: 'Link'
destination:
type: boolean
label: 'Include destination'
......@@ -8,8 +8,8 @@ entity_reference.default.handler_settings:
type: sequence
label: 'types'
sequence:
- type: string
label: 'Type'
type: string
label: 'Type'
sort:
type: mapping
label: 'Sort settings'
......@@ -31,8 +31,8 @@ entity_reference.default.handler_settings:
type: sequence
label: 'Restrict to the selected roles'
sequence:
- type: string
label: 'Role'
type: string
label: 'Role'
auto_create:
type: boolean
label: 'Create referenced entities if they don''t already exist'
......@@ -16,5 +16,5 @@ views.style.entity_reference:
type: sequence
label: 'Search fields'
sequence:
- type: string
label: 'Search field'
type: string
label: 'Search field'
......@@ -42,11 +42,11 @@ field.storage.*.*:
type: sequence
label: 'Indexes'
sequence:
- type: sequence
label: 'Indexes'
sequence:
- type: ignore
label: 'Index'
type: sequence
label: 'Indexes'
sequence:
type: ignore
label: 'Index'
persist_with_no_fields:
type: boolean
label: 'Persist field storage with no fields'
......
......@@ -36,8 +36,8 @@ views.field.field:
type: sequence
label: 'Group by columns'
sequence:
- type: string
label: 'Column'
type: string
label: 'Column'
group_rows:
type: boolean
label: 'Display all values in the same row'
......
......@@ -28,13 +28,13 @@ filter.format.*:
type: sequence
label: 'Roles'
sequence:
- type: string
label: 'Role'
type: string
label: 'Role'
filters:
type: sequence
label: 'Enabled filters'
sequence:
- type: filter
type: filter
langcode:
type: string
label: 'Default language'
......@@ -46,8 +46,8 @@ filter_settings.*:
type: sequence
label: 'Filter settings'
sequence:
- type: string
label: 'Value'
type: string
label: 'Value'
filter_settings.filter_html:
type: filter
......
......@@ -12,11 +12,11 @@ filter_settings.filter_test_restrict_tags_and_attributes:
type: sequence
label: 'Allowed tags and attributes'
sequence:
- type: ignore
label: 'Tag and optionally list of attributes'
type: ignore
label: 'Tag and optionally list of attributes'
forbidden_tags:
type: sequence
label: 'Forbidden tags'
sequence:
- type: boolean
label: 'Tag'
type: boolean
label: 'Tag'
......@@ -47,7 +47,7 @@ block.settings.forum_active_block:
type: sequence
label: 'Properties'
sequence:
- type: string
type: string
block_count:
type: integer
label: 'Block count'
......@@ -60,7 +60,7 @@ block.settings.forum_new_block:
type: sequence
label: 'Properties'
sequence:
- type: string
type: string
block_count:
type: integer
label: 'Block count'
......@@ -12,16 +12,16 @@ image.style.*:
effects:
type: sequence
sequence:
- type: mapping
mapping:
id:
type: string
data:
type: image.effect.[%parent.id]
weight: