diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index ef68a3e..4283543 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -638,6 +638,9 @@ field.integer.field_settings: suffix: type: string label: 'Suffix' + size: + type: string + label: 'Size' field.integer.value: type: sequence diff --git a/core/config/schema/core.entity.data_types.schema.yml b/core/config/schema/core.entity.data_types.schema.yml index f0b87ee..36e59fb 100644 --- a/core/config/schema/core.entity.data_types.schema.yml +++ b/core/config/schema/core.entity.data_types.schema.yml @@ -18,6 +18,9 @@ entity_field_view_display_base: label: type: string label: 'Label setting machine name' + settings: + type: sequence + label: 'Settings' # Schema for the base of the form mode display format settings. entity_field_form_display_base: @@ -34,3 +37,6 @@ entity_field_form_display_base: label: 'Third party settings' sequence: - type: entity_form_display.third_party.[%key] + settings: + type: sequence + label: 'Settings' diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml index 63a35eb..06a4215 100644 --- a/core/config/schema/core.entity.schema.yml +++ b/core/config/schema/core.entity.schema.yml @@ -145,35 +145,52 @@ entity_form_display.field.string_textfield: type: label label: 'Placeholder' -entity_form_display.field.datetime_timestamp: +entity_form_display.field.string_textarea: type: entity_field_form_display_base - label: 'Datetime timestamp display format settings' + label: 'Textarea display format settings' mapping: settings: - type: sequence + type: mapping label: 'Settings' - sequence: - - type: string + mapping: + rows: + type: integer + label: 'Rows' + placeholder: + type: label + label: 'Placeholder' + +entity_form_display.field.email_default: + type: entity_field_form_display_base + label: 'Email field display format settings' + mapping: + settings: + type: mapping + label: 'Settings' + mapping: + placeholder: + type: label + label: 'Placeholder' + +entity_form_display.field.datetime_timestamp: + type: entity_field_form_display_base + label: 'Datetime timestamp display format settings' entity_form_display.field.boolean_checkbox: type: entity_field_form_display_base label: 'Boolean checkbox display format settings' mapping: settings: - type: sequence + type: mapping label: 'Settings' - sequence: - - type: string + mapping: + display_label: + type: boolean + label: 'Display label' entity_form_display.field.hidden: type: entity_field_form_display_base label: '- Hidden - format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_form_display.field.number: type: entity_field_form_display_base @@ -238,29 +255,11 @@ entity_view_display.field.number_integer: entity_view_display.field.number_unformatted: type: entity_field_view_display_base label: 'Number unformatted display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.uri_link: type: entity_field_view_display_base label: 'URI as link display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.timestamp_ago: type: entity_field_view_display_base label: 'Timestamp ago display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string diff --git a/core/lib/Drupal/Core/Config/Schema/Element.php b/core/lib/Drupal/Core/Config/Schema/Element.php index c492d42..6f4fe9d 100644 --- a/core/lib/Drupal/Core/Config/Schema/Element.php +++ b/core/lib/Drupal/Core/Config/Schema/Element.php @@ -22,6 +22,13 @@ protected $value; /** + * The parent element object. + * + * @var Element + */ + protected $parent; + + /** * Create typed config object. */ protected function parseElement($key, $data, $definition) { @@ -37,4 +44,23 @@ protected function buildDataDefinition($definition, $value, $key) { return \Drupal::service('config.typed')->buildDataDefinition($definition, $value, $key, $this); } + /** + * Get the full config path of the element. + * + * @return string + * The full config path of the element starting with the top element key + * followed by a colon followed by element names separated with dots. + * For example: views.view.content:display.default.display_options. + */ + public function getFullName() { + if (isset($this->parent)) { + // Ensure if the parent was the root element, we do not add a dot after. + return str_replace(':.', ':', $this->parent->getFullName() . '.' . $this->getName()); + } + else { + // If there is no parent, this is the root element, add a colon. + return $this->getName() . ':'; + } + } + } diff --git a/core/lib/Drupal/Core/Config/Schema/Mapping.php b/core/lib/Drupal/Core/Config/Schema/Mapping.php index a85fac4..a8d6c53 100644 --- a/core/lib/Drupal/Core/Config/Schema/Mapping.php +++ b/core/lib/Drupal/Core/Config/Schema/Mapping.php @@ -63,7 +63,7 @@ public function get($property_name) { return $element; } else { - throw new \InvalidArgumentException(String::format("The configuration property @key doesn't exist.", array('@key' => $property_name))); + throw new \InvalidArgumentException(String::format("The configuration property @key.@element doesn't exist.", array('@key' => $this->getFullName(), '@element' => $property_name))); } } @@ -131,6 +131,11 @@ public function getPropertyDefinitions() { $this->propertyDefinitions = array(); foreach ($this->getAllKeys() as $key) { $definition = isset($this->definition['mapping'][$key]) ? $this->definition['mapping'][$key] : array(); + if (empty($definition)) { + debug($this->definition['type']); + debug($this->definition['debug']); + throw new \InvalidArgumentException(String::format("The configuration property @key.@element doesn't have schema.", array('@key' => $this->getFullName(), '@element' => $key))); + } $this->propertyDefinitions[$key] = $this->buildDataDefinition($definition, $this->value[$key], $key); } } diff --git a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php index 0fccd47..e8debe2 100644 --- a/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php +++ b/core/lib/Drupal/Core/Config/Schema/SchemaCheckTrait.php @@ -55,7 +55,7 @@ public function checkConfigSchema(TypedConfigManagerInterface $typed_config, $co } $definition = $typed_config->getDefinition($config_name); $data_definition = $typed_config->buildDataDefinition($definition, $config_data); - $this->schema = $typed_config->create($data_definition, $config_data); + $this->schema = $typed_config->create($data_definition, $config_data, $config_name); $errors = array(); foreach ($config_data as $key => $value) { $errors = array_merge($errors, $this->checkValue($key, $value)); diff --git a/core/lib/Drupal/Core/Config/StorableConfigBase.php b/core/lib/Drupal/Core/Config/StorableConfigBase.php index 5c6e8b3..5eab003 100644 --- a/core/lib/Drupal/Core/Config/StorableConfigBase.php +++ b/core/lib/Drupal/Core/Config/StorableConfigBase.php @@ -128,7 +128,7 @@ protected function getSchemaWrapper() { if (!isset($this->schemaWrapper)) { $definition = $this->typedConfigManager->getDefinition($this->name); $data_definition = $this->typedConfigManager->buildDataDefinition($definition, $this->data); - $this->schemaWrapper = $this->typedConfigManager->create($data_definition, $this->data); + $this->schemaWrapper = $this->typedConfigManager->create($data_definition, $this->data, $this->name); } return $this->schemaWrapper; } @@ -178,7 +178,10 @@ protected function validateValue($key, $value) { protected function castValue($key, $value) { $element = $this->getSchemaWrapper()->get($key); // Do not cast value if it is unknown or defined to be ignored. - if ($element && ($element instanceof Undefined || $element instanceof Ignore)) { + if ($element && ($element instanceof Undefined)) { + throw new ConfigException(String::format("The configuration property @key is undefined.", array('@key' => $element->getFullName()))); + } + elseif ($element && ($element instanceof Ignore)) { // Do validate the value (may throw UnsupportedDataTypeConfigException) // to ensure unsupported types are not supported in this case either. $this->validateValue($key, $value); diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index d775cc2..1943307 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -71,7 +71,7 @@ public function get($name) { $data = $this->configStorage->read($name); $type_definition = $this->getDefinition($name); $data_definition = $this->buildDataDefinition($type_definition, $data); - return $this->create($data_definition, $data); + return $this->create($data_definition, $data, $name); } /** @@ -91,7 +91,9 @@ public function buildDataDefinition(array $definition, $value, $name = NULL, $pa if (isset($name)) { $replace['%key'] = $name; } + $definition['debug']['dynamic_type'] = $type; $type = $this->replaceName($type, $replace); + $definition['debug']['resolved_type'] = $type; // Remove the type from the definition so that it is replaced with the // concrete type from schema definitions. unset($definition['type']); @@ -135,6 +137,7 @@ public function getDefinition($base_plugin_id, $exception_on_invalid = TRUE) { unset($definition['type']); $this->definitions[$type] = $definition; } + $definition['debug']['generic_type'] = $base_plugin_id; // Add type and default definition class. return $definition + array( 'definition_class' => '\Drupal\Core\TypedData\DataDefinition', diff --git a/core/modules/comment/config/schema/comment.schema.yml b/core/modules/comment/config/schema/comment.schema.yml index b5bcd86..8b8c6a3 100644 --- a/core/modules/comment/config/schema/comment.schema.yml +++ b/core/modules/comment/config/schema/comment.schema.yml @@ -5,20 +5,16 @@ entity_view_display.field.comment_default: label: 'Comment display format settings' mapping: settings: - type: sequence + type: mapping label: 'Settings' - sequence: - - type: string + mapping: + pager_id: + type: integer + label: 'Pager ID' entity_form_display.field.comment_default: type: entity_field_form_display_base label: 'Comment display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string action.configuration.comment_publish_action: type: action_configuration_default diff --git a/core/modules/datetime/config/schema/datetime.schema.yml b/core/modules/datetime/config/schema/datetime.schema.yml index 58e4cc6..3086164 100644 --- a/core/modules/datetime/config/schema/datetime.schema.yml +++ b/core/modules/datetime/config/schema/datetime.schema.yml @@ -41,12 +41,6 @@ entity_view_display.field.datetime_default: entity_view_display.field.datetime_plain: type: entity_field_view_display_base label: 'Datetime plain display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_form_display.field.datetime_datelist: type: entity_field_form_display_base @@ -69,9 +63,3 @@ entity_form_display.field.datetime_datelist: entity_form_display.field.datetime_default: type: entity_field_form_display_base label: 'Datetime default display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string diff --git a/core/modules/datetime/src/Tests/DateTimeFieldTest.php b/core/modules/datetime/src/Tests/DateTimeFieldTest.php index 281e78c..c7c7047 100644 --- a/core/modules/datetime/src/Tests/DateTimeFieldTest.php +++ b/core/modules/datetime/src/Tests/DateTimeFieldTest.php @@ -141,6 +141,7 @@ function testDateField() { // Verify that the plain formatter works. $this->display_options['type'] = 'datetime_plain'; + $this->display_options['settings'] = array(); entity_get_display($this->field->entity_type, $this->field->bundle, 'full') ->setComponent($field_name, $this->display_options) ->save(); @@ -206,6 +207,7 @@ function testDatetimeField() { // Verify that the plain formatter works. $this->display_options['type'] = 'datetime_plain'; + $this->display_options['settings'] = array(); entity_get_display($this->field->entity_type, $this->field->bundle, 'full') ->setComponent($field_name, $this->display_options) ->save(); diff --git a/core/modules/entity_reference/config/schema/entity_reference.schema.yml b/core/modules/entity_reference/config/schema/entity_reference.schema.yml index 5404963..22561c9 100644 --- a/core/modules/entity_reference/config/schema/entity_reference.schema.yml +++ b/core/modules/entity_reference/config/schema/entity_reference.schema.yml @@ -55,12 +55,6 @@ entity_view_display.field.entity_reference_entity_view: entity_view_display.field.entity_reference_entity_id: type: entity_field_view_display_base label: 'Entity reference entity ID display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.entity_reference_label: type: entity_field_view_display_base diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php index ca1fbb0..9c5d5cd 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -49,7 +49,7 @@ function testNumberDecimalField() { 'entity_type' => 'entity_test', 'type' => 'decimal', 'settings' => array( - 'precision' => 8, 'scale' => 4, 'decimal_separator' => '.', + 'precision' => 8, 'scale' => 4, ) ))->save(); entity_create('field_config', array( diff --git a/core/modules/file/config/schema/file.schema.yml b/core/modules/file/config/schema/file.schema.yml index cd21f38..0babe38 100644 --- a/core/modules/file/config/schema/file.schema.yml +++ b/core/modules/file/config/schema/file.schema.yml @@ -70,43 +70,18 @@ field.file.field_settings: entity_view_display.field.file_default: type: entity_field_view_display_base label: 'Generic file format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.file_rss_enclosure: type: entity_field_view_display_base label: 'RSS enclosure format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.file_table: type: entity_field_view_display_base label: 'Table of files format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.file_url_plain: type: entity_field_view_display_base label: 'URL to file format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string - entity_form_display.field.file_generic: type: entity_field_form_display_base diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml index f0db0d5..2ecd1de 100644 --- a/core/modules/image/config/schema/image.schema.yml +++ b/core/modules/image/config/schema/image.schema.yml @@ -139,10 +139,15 @@ entity_view_display.field.image: label: 'Image field display format settings' mapping: settings: - type: sequence - label: 'Format settings' - sequence: - - type: string + type: mapping + label: 'Settings' + mapping: + image_link: + type: string + label: 'Link image to' + image_style: + type: string + label: 'Image style' entity_form_display.field.image_image: type: entity_field_form_display_base @@ -150,7 +155,7 @@ entity_form_display.field.image_image: mapping: settings: type: mapping - label: 'Format settings' + label: 'Settings' mapping: progress_indicator: type: string diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php index c49af3c..2111d32 100644 --- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php +++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php @@ -175,7 +175,6 @@ function testImageFieldSettings() { 'max_resolution' => '100x100', 'min_resolution' => '10x10', 'title_field' => 1, - 'description' => '[site:name]_description', ); $widget_settings = array( 'preview_image_style' => 'medium', diff --git a/core/modules/options/config/schema/options.schema.yml b/core/modules/options/config/schema/options.schema.yml index 03cb81f..f0d444a 100644 --- a/core/modules/options/config/schema/options.schema.yml +++ b/core/modules/options/config/schema/options.schema.yml @@ -114,39 +114,15 @@ field.list_string.value: entity_view_display.field.list_default: type: entity_field_view_display_base label: 'Options list default display settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.list_key: type: entity_field_view_display_base label: 'Key format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_form_display.field.options_buttons: type: entity_field_form_display_base label: 'Check boxes/radio buttons format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_form_display.field.options_select: type: entity_field_form_display_base label: 'Select list format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string diff --git a/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml b/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml index b24ca9e..c3540f9 100644 --- a/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml +++ b/core/modules/options/tests/options_config_install_test/config/install/core.entity_form_display.node.options_install_test.default.yml @@ -36,13 +36,13 @@ content: promote: type: boolean_checkbox settings: - display_label: '1' + display_label: true weight: 15 third_party_settings: { } sticky: type: boolean_checkbox settings: - display_label: '1' + display_label: true weight: 16 third_party_settings: { } body: diff --git a/core/modules/path/config/schema/path.schema.yml b/core/modules/path/config/schema/path.schema.yml index f595e4b..ebed69c 100644 --- a/core/modules/path/config/schema/path.schema.yml +++ b/core/modules/path/config/schema/path.schema.yml @@ -3,6 +3,3 @@ entity_form_display.field.path: type: entity_field_form_display_base label: 'Link format settings' - mapping: - settings: - type: sequence diff --git a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php index 5f85234..f060ba3 100644 --- a/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php +++ b/core/modules/responsive_image/src/Tests/ResponsiveImageFieldDisplayTest.php @@ -101,7 +101,6 @@ public function _testResponsiveImageFieldFormatters($scheme) { // Use the responsive image formatter linked to file formatter. $display_options = array( 'type' => 'responsive_image', - 'module' => 'responsive_image', 'settings' => array( 'image_link' => 'file' ), diff --git a/core/modules/taxonomy/config/schema/taxonomy.schema.yml b/core/modules/taxonomy/config/schema/taxonomy.schema.yml index 579f673..e9aed2b 100644 --- a/core/modules/taxonomy/config/schema/taxonomy.schema.yml +++ b/core/modules/taxonomy/config/schema/taxonomy.schema.yml @@ -94,12 +94,6 @@ entity_view_display.field.taxonomy_term_reference_rss_category: entity_view_display.field.taxonomy_term_reference_link: type: entity_field_view_display_base label: 'Taxonomy format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_form_display.field.taxonomy_autocomplete: type: entity_field_form_display_base diff --git a/core/modules/text/config/schema/text.schema.yml b/core/modules/text/config/schema/text.schema.yml index f472aec..f211cbf 100644 --- a/core/modules/text/config/schema/text.schema.yml +++ b/core/modules/text/config/schema/text.schema.yml @@ -93,12 +93,6 @@ field.text_with_summary.value: entity_view_display.field.text_default: type: entity_field_view_display_base label: 'Formatted text default display format settings' - mapping: - settings: - type: sequence - label: 'Settings' - sequence: - - type: string entity_view_display.field.text_summary_or_trimmed: type: entity_field_view_display_base