diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 0c9ad70..9ce4133 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -269,6 +269,11 @@ config_entity: dependencies: type: config_dependencies label: 'Dependencies' + third_party_settings: + type: sequence + label: 'Third party settings' + sequence: + - type: '[%parent.%definition_type].third_party.[%key]' block_settings: type: mapping @@ -393,11 +398,6 @@ field_config_base: label: 'Default value callback' settings: type: field.field_settings.[%parent.field_type] - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: field_config.third_party.[%key] field_type: type: string label: 'Field type' diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml index ee3d5d7..de9530d 100644 --- a/core/config/schema/core.entity.schema.yml +++ b/core/config/schema/core.entity.schema.yml @@ -93,11 +93,6 @@ core.entity_view_display.*.*.*: sequence: - type: boolean label: 'Value' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: entity_view_display.third_party.[%key] # Overview configuration information for form mode displays. core.entity_form_display.*.*.*: @@ -146,11 +141,6 @@ core.entity_form_display.*.*.*: sequence: - type: boolean label: 'Component' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: entity_form_display.third_party.[%key] # Default schema for entity display field with undefined type. field.formatter.settings.*: diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php index 12a4543..b587f63 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php @@ -7,12 +7,12 @@ namespace Drupal\Core\Config\Entity; -use Drupal\Component\Plugin\ConfigurablePluginInterface; use Drupal\Component\Utility\String; use Drupal\Core\Cache\Cache; use Drupal\Core\Config\Schema\SchemaIncompleteException; use Drupal\Core\Entity\Entity; use Drupal\Core\Config\ConfigDuplicateUUIDException; +use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityWithPluginCollectionInterface; @@ -30,6 +30,8 @@ addDependency as addDependencyTrait; } + use ThirdPartySettingsTrait; + /** * The original ID of the configuration entity. * @@ -259,6 +261,9 @@ public function toArray() { $properties[$name] = $this->get($name); } } + if (empty($this->third_party_settings)) { + unset($properties['third_party_settings']); + } return $properties; } diff --git a/core/lib/Drupal/Core/Config/TypedConfigManager.php b/core/lib/Drupal/Core/Config/TypedConfigManager.php index a784364..6dfc54c 100644 --- a/core/lib/Drupal/Core/Config/TypedConfigManager.php +++ b/core/lib/Drupal/Core/Config/TypedConfigManager.php @@ -238,6 +238,7 @@ protected function replaceName($name, $data) { * their value or some of these special strings: * - '%key', will be replaced by the element's key. * - '%parent', to reference the parent element. + * - '%definition_type', to reference the definition type of the parent. * * There may be nested configuration keys separated by dots or more complex * patterns like '%parent.name' which references the 'name' value of the @@ -260,6 +261,13 @@ protected function replaceVariable($value, $data) { $parts = explode('.', $value); // Process each value part, one at a time. while ($name = array_shift($parts)) { + if ($name == '%definition_type') { + if ($data['%parent']) { + /** @var \Drupal\Core\Config\Schema\ArrayElement $parent */ + $parent = $data['%parent']; + return $parent->getDataDefinition()->getDataType(); + } + } if (!is_array($data) || !isset($data[$name])) { // Key not found, return original value return $value; diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index a1c8e84..225d407 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Entity; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\field\Entity\FieldConfig; @@ -20,8 +19,6 @@ */ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDisplayInterface { - use ThirdPartySettingsTrait; - /** * The 'mode' for runtime EntityDisplay objects used to render entities with * arbitrary display options rather than a configured view mode or form mode. diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index af1c399..7388b4b 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -9,7 +9,6 @@ use Drupal\Component\Plugin\DependentPluginInterface; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; @@ -20,8 +19,6 @@ */ abstract class FieldConfigBase extends ConfigEntityBase implements FieldConfigInterface { - use ThirdPartySettingsTrait; - /** * The field ID. * diff --git a/core/modules/config/src/Tests/ConfigSchemaTest.php b/core/modules/config/src/Tests/ConfigSchemaTest.php index c7a6f55..c619a0d 100644 --- a/core/modules/config/src/Tests/ConfigSchemaTest.php +++ b/core/modules/config/src/Tests/ConfigSchemaTest.php @@ -25,7 +25,7 @@ class ConfigSchemaTest extends KernelTestBase { * * @var array */ - public static $modules = array('system', 'language', 'locale', 'field', 'image', 'config_schema_test'); + public static $modules = array('system', 'language', 'locale', 'field', 'image', 'config_test', 'config_schema_test'); /** * {@inheritdoc} @@ -171,7 +171,7 @@ function testSchemaMapping() { $expected['mapping']['effects']['sequence'][0]['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'] = 'image_style.third_party.[%key]'; + $expected['mapping']['third_party_settings']['sequence'][0]['type'] = '[%parent.%definition_type].third_party.[%key]'; $expected['type'] = 'image.style.*'; $this->assertEqual($definition, $expected); @@ -202,6 +202,19 @@ function testSchemaMapping() { $this->assertEqual($definition, $expected, 'Retrieved the right metadata for the first effect of image.style.medium'); + $test = \Drupal::service('config.typed')->get('config_test.dynamic.third_party')->get('third_party_settings.config_schema_test'); + $definition = $test->getDataDefinition()->toArray(); + $expected = array(); + $expected['type'] = 'config_test.dynamic.*.third_party.config_schema_test'; + $expected['label'] = 'Mapping'; + $expected['class'] = '\Drupal\Core\Config\Schema\Mapping'; + $expected['definition_class'] = '\Drupal\Core\TypedData\MapDataDefinition'; + $expected['mapping'] = [ + 'integer' => ['type' => 'integer'], + 'string' => ['type' => 'string'], + ]; + $this->assertEqual($definition, $expected, 'Retrieved the right metadata for config_test.dynamic.third_party:third_party_settings.config_schema_test'); + // More complex, several level deep test. $definition = \Drupal::service('config.typed')->getDefinition('config_schema_test.someschema.somemodule.section_one.subsection'); // This should be the schema of config_schema_test.someschema.somemodule.*.*. diff --git a/core/modules/config/tests/config_schema_test/config/install/config_test.dynamic.third_party.yml b/core/modules/config/tests/config_schema_test/config/install/config_test.dynamic.third_party.yml new file mode 100644 index 0000000..3db9b1d --- /dev/null +++ b/core/modules/config/tests/config_schema_test/config/install/config_test.dynamic.third_party.yml @@ -0,0 +1,8 @@ +id: third_party +label: Default +weight: 0 +protected_property: Default +third_party_settings: + config_schema_test: + integer: 1 + string: 'string' diff --git a/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml b/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml index cbc3c61..26dbdaf 100644 --- a/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml +++ b/core/modules/config/tests/config_schema_test/config/schema/config_schema_test.schema.yml @@ -207,3 +207,10 @@ test_with_parents.plugin_types.*: value: type: string +config_test.dynamic.*.third_party.config_schema_test: + type: mapping + mapping: + integer: + type: integer + string: + type: string diff --git a/core/modules/contact/config/schema/contact.schema.yml b/core/modules/contact/config/schema/contact.schema.yml index 011ae37..7ebb6f4 100644 --- a/core/modules/contact/config/schema/contact.schema.yml +++ b/core/modules/contact/config/schema/contact.schema.yml @@ -22,11 +22,6 @@ contact.form.*: weight: type: integer label: 'Weight' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: contact_form.third_party.[%key] contact.settings: type: mapping diff --git a/core/modules/contact/src/Entity/ContactForm.php b/core/modules/contact/src/Entity/ContactForm.php index d4be3de..c0cf26a 100644 --- a/core/modules/contact/src/Entity/ContactForm.php +++ b/core/modules/contact/src/Entity/ContactForm.php @@ -9,7 +9,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\contact\ContactFormInterface; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; /** * Defines the contact form entity. @@ -42,8 +41,6 @@ */ class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface { - use ThirdPartySettingsTrait; - /** * The form ID. * diff --git a/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml b/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml index e421214..489301e 100644 --- a/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml +++ b/core/modules/contact/tests/modules/contact_storage_test/config/schema/contact_storage_test.schema.yml @@ -1,6 +1,6 @@ # Schema for configuration files of the Contact Storage Test module. -contact_form.third_party.contact_storage_test: +contact.form.*.third_party.contact_storage_test: type: mapping label: 'Per-contact form storage settings' mapping: diff --git a/core/modules/content_translation/config/schema/content_translation.schema.yml b/core/modules/content_translation/config/schema/content_translation.schema.yml index 1e724d8..ee2af64 100644 --- a/core/modules/content_translation/config/schema/content_translation.schema.yml +++ b/core/modules/content_translation/config/schema/content_translation.schema.yml @@ -1,6 +1,6 @@ # Schema for the Content Translation module. -field_config.third_party.content_translation: +field.field.*.*.*.third_party.content_translation: type: mapping label: 'Content translation field settings' mapping: @@ -11,7 +11,7 @@ field_config.third_party.content_translation: - type: string label: 'Field column for which to synchronize translations' -language.content_settings.third_party.content_translation: +language.entity.*.third_party.content_translation: type: mapping label: 'Content translation content settings' mapping: diff --git a/core/modules/image/config/schema/image.schema.yml b/core/modules/image/config/schema/image.schema.yml index 87f38f6..00268ef 100644 --- a/core/modules/image/config/schema/image.schema.yml +++ b/core/modules/image/config/schema/image.schema.yml @@ -22,11 +22,6 @@ image.style.*: type: integer uuid: type: string - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: image_style.third_party.[%key] image.effect.*: type: mapping diff --git a/core/modules/image/src/Entity/ImageStyle.php b/core/modules/image/src/Entity/ImageStyle.php index 4c37751..a3c7ab5 100644 --- a/core/modules/image/src/Entity/ImageStyle.php +++ b/core/modules/image/src/Entity/ImageStyle.php @@ -9,7 +9,6 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityWithPluginCollectionInterface; use Drupal\Core\Routing\RequestHelper; @@ -54,8 +53,6 @@ */ class ImageStyle extends ConfigEntityBase implements ImageStyleInterface, EntityWithPluginCollectionInterface { - use ThirdPartySettingsTrait; - /** * The name of the image style to use as replacement upon delete. * diff --git a/core/modules/image/tests/modules/image_module_test/config/schema/image_module_test.schema.yml b/core/modules/image/tests/modules/image_module_test/config/schema/image_module_test.schema.yml index a36719d..b723878 100644 --- a/core/modules/image/tests/modules/image_module_test/config/schema/image_module_test.schema.yml +++ b/core/modules/image/tests/modules/image_module_test/config/schema/image_module_test.schema.yml @@ -1,4 +1,4 @@ -image_style.third_party.image_module_test: +image_style.*.third_party.image_module_test: type: mapping label: 'Schema for image_module_test module additions to image_style entity' mapping: diff --git a/core/modules/language/config/schema/language.schema.yml b/core/modules/language/config/schema/language.schema.yml index d894eb6..bd03869 100644 --- a/core/modules/language/config/schema/language.schema.yml +++ b/core/modules/language/config/schema/language.schema.yml @@ -120,11 +120,6 @@ language.content_settings.*.*: language_alterable: type: boolean label: 'Allow to alter the language' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: language.content_settings.third_party.[%key] condition.plugin.language: type: condition.plugin diff --git a/core/modules/language/src/Entity/ContentLanguageSettings.php b/core/modules/language/src/Entity/ContentLanguageSettings.php index 607fb4c..19ca584 100644 --- a/core/modules/language/src/Entity/ContentLanguageSettings.php +++ b/core/modules/language/src/Entity/ContentLanguageSettings.php @@ -9,7 +9,6 @@ use Drupal\Component\Utility\String; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\language\ContentLanguageSettingsException; @@ -30,8 +29,6 @@ */ class ContentLanguageSettings extends ConfigEntityBase implements ContentLanguageSettingsInterface { - use ThirdPartySettingsTrait; - /** * The id. Combination of $target_entity_type_id.$target_bundle. * diff --git a/core/modules/menu_ui/config/schema/menu_ui.schema.yml b/core/modules/menu_ui/config/schema/menu_ui.schema.yml index ed1fef8..ad096f2 100644 --- a/core/modules/menu_ui/config/schema/menu_ui.schema.yml +++ b/core/modules/menu_ui/config/schema/menu_ui.schema.yml @@ -8,7 +8,7 @@ menu_ui.settings: type: boolean label: 'Override parent selector' -node_type.third_party.menu_ui: +node.type.*.third_party.menu_ui: type: mapping label: 'Per-content type menu settings' mapping: diff --git a/core/modules/node/config/schema/node.schema.yml b/core/modules/node/config/schema/node.schema.yml index f650794..9b8931c 100644 --- a/core/modules/node/config/schema/node.schema.yml +++ b/core/modules/node/config/schema/node.schema.yml @@ -33,11 +33,6 @@ node.type.*: display_submitted: type: boolean label: 'Display setting for author and date Submitted by post information' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: node_type.third_party.[%key] # Plugin \Drupal\node\Plugin\Search\NodeSearch search.plugin.node_search: diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php index 8a08d26..238ae8f 100644 --- a/core/modules/node/src/Entity/NodeType.php +++ b/core/modules/node/src/Entity/NodeType.php @@ -8,7 +8,6 @@ namespace Drupal\node\Entity; use Drupal\Core\Config\Entity\ConfigEntityBundleBase; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\node\NodeTypeInterface; @@ -42,7 +41,6 @@ * ) */ class NodeType extends ConfigEntityBundleBase implements NodeTypeInterface { - use ThirdPartySettingsTrait; /** * The machine name of this node type. diff --git a/core/modules/system/tests/modules/entity_test/config/schema/entity_test.schema.yml b/core/modules/system/tests/modules/entity_test/config/schema/entity_test.schema.yml index 5a3ad02..d671bc4 100644 --- a/core/modules/system/tests/modules/entity_test/config/schema/entity_test.schema.yml +++ b/core/modules/system/tests/modules/entity_test/config/schema/entity_test.schema.yml @@ -1,4 +1,4 @@ -entity_view_display.third_party.entity_test: +core.entity_view_display.*.*.*.third_party.entity_test: type: mapping label: 'Schema for entity_test module additions to entity_view_display entity' mapping: diff --git a/core/modules/taxonomy/config/schema/taxonomy.schema.yml b/core/modules/taxonomy/config/schema/taxonomy.schema.yml index cf4a3a9..c79fa5f 100644 --- a/core/modules/taxonomy/config/schema/taxonomy.schema.yml +++ b/core/modules/taxonomy/config/schema/taxonomy.schema.yml @@ -33,11 +33,6 @@ taxonomy.vocabulary.*: weight: type: integer label: 'Weight' - third_party_settings: - type: sequence - label: 'Third party settings' - sequence: - - type: taxonomy.vocabulary.third_party.[%key] field.storage_settings.taxonomy_term_reference: type: base_entity_reference_field_settings diff --git a/core/modules/taxonomy/src/Entity/Vocabulary.php b/core/modules/taxonomy/src/Entity/Vocabulary.php index 4f21f8a..ae7b10f 100644 --- a/core/modules/taxonomy/src/Entity/Vocabulary.php +++ b/core/modules/taxonomy/src/Entity/Vocabulary.php @@ -8,7 +8,6 @@ namespace Drupal\taxonomy\Entity; use Drupal\Core\Config\Entity\ConfigEntityBundleBase; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\taxonomy\VocabularyInterface; @@ -46,7 +45,6 @@ * ) */ class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface { - use ThirdPartySettingsTrait; /** * The taxonomy vocabulary ID. diff --git a/core/modules/taxonomy/tests/modules/taxonomy_crud/config/schema/taxonomy_crud.schema.yml b/core/modules/taxonomy/tests/modules/taxonomy_crud/config/schema/taxonomy_crud.schema.yml index fdbed04..fdbffe9 100644 --- a/core/modules/taxonomy/tests/modules/taxonomy_crud/config/schema/taxonomy_crud.schema.yml +++ b/core/modules/taxonomy/tests/modules/taxonomy_crud/config/schema/taxonomy_crud.schema.yml @@ -1,4 +1,4 @@ -taxonomy.vocabulary.third_party.taxonomy_crud: +taxonomy.vocabulary.*.third_party.taxonomy_crud: type: mapping label: 'Schema for taxonomy_crud module additions to vocabulary entity' mapping: diff --git a/core/tests/Drupal/Tests/Core/Config/Entity/Fixtures/ConfigEntityBaseWithThirdPartySettings.php b/core/tests/Drupal/Tests/Core/Config/Entity/Fixtures/ConfigEntityBaseWithThirdPartySettings.php index 6834e63..100999c 100644 --- a/core/tests/Drupal/Tests/Core/Config/Entity/Fixtures/ConfigEntityBaseWithThirdPartySettings.php +++ b/core/tests/Drupal/Tests/Core/Config/Entity/Fixtures/ConfigEntityBaseWithThirdPartySettings.php @@ -9,7 +9,6 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ThirdPartySettingsInterface; -use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; /** * Enables testing of dependency calculation. @@ -18,6 +17,5 @@ * @see \Drupal\Core\Config\Entity\ConfigEntityBase::calculateDependencies() */ abstract class ConfigEntityBaseWithThirdPartySettings extends ConfigEntityBase implements ThirdPartySettingsInterface { - use ThirdPartySettingsTrait; }