Commit bfb8fdf9 authored by alexpott's avatar alexpott

Issue #2268439 by Gábor Hojtsy: String introspection backwards data typing is...

Issue #2268439 by Gábor Hojtsy: String introspection backwards data typing is confusing / incorrect.
parent 50197bc8
......@@ -91,13 +91,8 @@ public function get($name) {
*/
public function create(array $definition, $value = NULL, $name = NULL, $parent = NULL) {
if (!isset($definition['type'])) {
// Set default type 'string' if possible. If not it will be 'undefined'.
if (is_string($value)) {
$definition['type'] = 'string';
}
else {
$definition['type'] = 'undefined';
}
// By default elements without a type are undefined.
$definition['type'] = 'undefined';
}
elseif (strpos($definition['type'], ']')) {
// Replace variable names in definition.
......
......@@ -68,15 +68,15 @@ function testSchemaMapping() {
$definition = $config['testitem']->getDataDefinition();
$expected = array();
$expected['label'] = 'Test item';
$expected['class'] = '\Drupal\Core\TypedData\Plugin\DataType\String';
$expected['type'] = 'string';
$this->assertEqual($definition, $expected, 'Automatic type detection on string item worked.');
$expected['class'] = '\Drupal\Core\Config\Schema\Property';
$expected['type'] = 'undefined';
$this->assertEqual($definition, $expected, 'Automatic type detected for a scalar is undefined.');
$definition = $config['testlist']->getDataDefinition();
$expected = array();
$expected['label'] = 'Test list';
$expected['class'] = '\Drupal\Core\Config\Schema\Property';
$expected['type'] = 'undefined';
$this->assertEqual($definition, $expected, 'Automatic type fallback on non-string item worked.');
$this->assertEqual($definition, $expected, 'Automatic type detected for a list is undefined.');
// Simple case, straight metadata.
$definition = \Drupal::service('config.typed')->getDefinition('system.maintenance');
......
......@@ -20,21 +20,25 @@ views_display:
label: 'Pager'
mapping:
type:
type: string
label: 'Pager type'
options:
type: views.pager.[%parent.type]
provider:
type: string
label: 'Provider'
exposed_form:
type: mapping
label: 'Exposed form'
mapping:
type:
type: string
label: 'Exposed form type'
options:
label: 'Options'
type: views.exposed_form.[%parent.type]
provider:
type: string
label: 'Provider'
access:
type: mapping
......@@ -46,14 +50,17 @@ views_display:
options:
type: views.access.[%parent.type]
provider:
type: string
label: 'Provider'
cache:
type: views.cache.[type]
label: 'Caching'
mapping:
type:
type: string
label: 'Cache type'
provider:
type: string
label: 'Provider'
empty:
type: sequence
......@@ -93,20 +100,24 @@ views_display:
label: 'Format'
mapping:
type:
type: string
label: 'Type'
options:
type: views.style.[%parent.type]
provider:
type: string
label: 'Provider'
row:
type: mapping
label: 'Row'
mapping:
type:
type: string
label: 'Row type'
options:
type: views.row.[%parent.type]
provider:
type: string
label: 'Provider'
query:
type: mapping
......@@ -118,6 +129,7 @@ views_display:
options:
type: views.query.[%parent.type]
provider:
type: string
label: 'Provider'
defaults:
type: mapping
......
......@@ -79,24 +79,31 @@ views.view.*:
type: boolean
label: 'Status'
module:
type: string
label: 'Module'
id:
type: string
label: 'Machine name'
description:
type: text
label: 'Administrative description'
tag:
type: string
label: 'Tag'
base_table:
type: string
label: 'Base table'
base_field:
type: string
label: 'Base field'
label:
type: label
label: 'Human readable name'
core:
type: string
label: 'Drupal version'
uuid:
type: string
label: 'UUID'
display:
type: sequence
......@@ -106,11 +113,13 @@ views.view.*:
label: 'Display settings'
mapping:
id:
type: string
label: 'Machine name'
display_title:
type: text
label: 'Title'
display_plugin:
type: string
label: 'Display plugin'
position:
type: integer
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment