Commit 6daf6f63 authored by webchick's avatar webchick

Issue #1953404 by vijaycs85, yched, Gábor Hojtsy: Add config schema to field...

Issue #1953404 by vijaycs85, yched, Gábor Hojtsy: Add config schema to field and instance config entities.
parent 986bfe36
......@@ -13,3 +13,131 @@ field.settings:
purge_batch_size:
type: integer
label: 'Maximum number of field data records to purge'
field.field.*:
type: mapping
label: 'Field'
mapping:
id:
type: string
label: 'Machine name'
uuid:
type: string
label: 'UUID'
status:
type: boolean
label: 'Status'
langcode:
type: string
label: 'Default language'
type:
type: string
label: 'Type'
settings:
type: field.[%parent.type].settings
module:
type: string
label: 'Module'
active:
type: boolean
label: 'Active'
entity_types:
type: sequence
label: 'Allowed entity types'
sequence:
- type: string
label: 'Entity type'
storage:
type: mapping
label: 'Storage'
mapping:
type:
type: string
label: 'Type'
settings:
type: field_storage.[%parent.type].settings
label: 'Settings'
module:
type: string
label: 'Module'
active:
type: boolean
label: 'Active'
locked:
type: boolean
label: 'Locked'
cardinality:
type: integer
label: 'Maximum number of values users can enter'
translatable:
type: boolean
label: 'Translatable'
indexes:
type: sequence
label: 'Indexes'
sequence:
- type: sequence
label: 'Indexes'
sequence:
- type: string
label: 'Column'
field.instance.*.*.*:
type: mapping
label: 'Field instance'
mapping:
id:
type: string
label: 'ID'
uuid:
type: string
label: 'UUID'
status:
type: boolean
label: 'Status'
langcode:
type: string
label: 'Default language'
field_uuid:
type: string
label: 'Field UUID'
entity_type:
type: string
label: 'Allowed entity types'
bundle:
type: string
label: 'Bundle'
label:
type: label
label: 'Label'
description:
type: text
label: 'Help text'
required:
type: boolean
label: 'Required field'
default_value:
type: field.[%parent.field_type].value
default_value_function:
type: string
label: 'Default value funtion'
settings:
type: field.[%parent.field_type].instance_settings
widget:
type: mapping
label: 'Widget'
mapping:
weight:
type: integer
label: 'Weight'
type:
type: string
label: 'Widget type'
settings:
type: field_widget.[%parent.type].settings
module:
type: string
label: 'Module'
field_type:
type: string
label: 'Field type'
......@@ -350,7 +350,7 @@ function field_update_8003() {
$deleted_fields = $state->get('field.field.deleted') ?: array();
$deleted_instances = $state->get('field.instance.deleted') ?: array();
$field_uuids = array();
$field_data = array();
// Migrate field definitions.
$records = db_query("SELECT * FROM {field_config}")->fetchAll(PDO::FETCH_ASSOC);
......@@ -411,8 +411,12 @@ function field_update_8003() {
}
}
// Store the UUID with the old field_id so that we can map the instances.
$field_uuids[$record['id']] = $config['uuid'];
// Store the UUID and field type, they will be used when processing
// instances.
$field_data[$record['id']] = array(
'uuid' => $config['uuid'],
'type' => $record['type'],
);
}
// Migrate instance definitions.
......@@ -423,7 +427,8 @@ function field_update_8003() {
$config = array(
'id' => $record['entity_type'] . '.' . $record['bundle'] . '.' . $record['field_name'],
'uuid' => $uuid->generate(),
'field_uuid' => $field_uuids[$record['field_id']],
'field_uuid' => $field_data[$record['field_id']]['uuid'],
'field_type' => $field_data[$record['field_id']]['type'],
'entity_type' => $record['entity_type'],
'bundle' => $record['bundle'],
'label' => $record['data']['label'],
......
......@@ -253,6 +253,10 @@ public function __construct(array $values, $entity_type = 'field_instance') {
unset($values['field_name']);
$this->field = $field;
// Discard the 'field_type' entry that is added in config records to ease
// schema generation. See getExportProperties().
unset($values['field_type']);
// Check required properties.
if (empty($values['entity_type'])) {
throw new FieldException(format_string('Attempt to create an instance of field @field_id without an entity type.', array('@field_id' => $this->field->id)));
......@@ -308,6 +312,11 @@ public function getExportProperties() {
foreach ($names as $name) {
$properties[$name] = $this->get($name);
}
// Additionally, include the field type, that is needed to be able to
// generate the field-type-dependant parts of the config schema.
$properties['field_type'] = $this->field->type;
return $properties;
}
......
# Schema for configuration files of the Field SQL Storage module.
field_storage.field_sql_storage.settings:
type: sequence
label: 'Settings'
sequence:
- type: string
......@@ -137,6 +137,7 @@ function testFieldUpgradeToConfig() {
$this->assertEqual($config, array(
'id' => "node.$node_type.body",
'field_uuid' => $field_uuid,
'field_type' => 'text_with_summary',
'entity_type' => 'node',
'bundle' => $node_type,
'label' => 'Body',
......
......@@ -7,3 +7,140 @@ text.settings:
default_summary_length:
type: integer
label: 'Default summary length'
field.text.settings:
type: mapping
label: 'Text settings'
mapping:
max_length:
type: integer
label: 'Maximum length'
field.text.instance_settings:
type: mapping
label: 'Text settings'
mapping:
text_processing:
type: string
label: 'Text processing'
user_register_form:
type: boolean
label: 'Display on user registration form.'
field.text.value:
type: sequence
label: 'Default value'
sequence:
- type: mapping
label: 'Default'
mapping:
value:
type: label
label: 'Value'
format:
type: string
label: 'Text format'
field.text_long.settings:
type: sequence
label: 'Settings'
sequence:
- type: string
field.text_long.instance_settings:
type: mapping
label: 'Long text settings'
mapping:
text_processing:
type: string
label: 'Text processing'
user_register_form:
type: boolean
label: 'Display on user registration form.'
field.text_long.value:
type: sequence
label: 'Default value'
sequence:
- type: mapping
label: 'Default'
mapping:
value:
type: text
label: 'Value'
format:
type: string
label: 'Text format'
field.text_with_summary.settings:
type: sequence
label: 'Default'
sequence:
- type: string
field.text_with_summary.instance_settings:
type: mapping
label: 'Text area with a summary'
mapping:
text_processing:
type: boolean
label: 'Text processing'
display_summary:
type: boolean
label: 'Summary input'
user_register_form:
type: boolean
label: 'Display on user registration form.'
field.text_with_summary.value:
type: sequence
label: 'Default value'
sequence:
- type: mapping
label: 'Default'
mapping:
value:
type: text
label: 'Body'
summary:
type: string
label: 'Summary'
format:
type: string
label: 'Text format'
field_widget.text_textfield.settings:
type: mapping
label: 'Text field widget settings'
mapping:
size:
type: integer
label: 'Size of textfield'
placeholder:
type: label
label: 'Placeholder'
field_widget.text_textarea.settings:
type: mapping
label: 'Long text widget settings'
mapping:
rows:
type: integer
label: 'Rows'
placeholder:
type: label
label: 'Placeholder'
field_widget.text_textarea_with_summary.settings:
type: mapping
label: 'Text area widget settings'
mapping:
rows:
type: integer
label: 'Rows'
summary_rows:
type: integer
label: 'Summary rows'
placeholder:
type: label
label: 'Placeholder'
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