diff --git a/core/config/schema/core.data_types.schema.yml b/core/config/schema/core.data_types.schema.yml index 41332e3..c8c69af 100644 --- a/core/config/schema/core.data_types.schema.yml +++ b/core/config/schema/core.data_types.schema.yml @@ -566,7 +566,7 @@ field.field_settings.entity_reference: type: string label: 'Reference method' handler_settings: - type: entity_reference.[%parent.handler].handler_settings + type: entity_reference.handler_settings.[plugin_id] label: 'Reference method settings' field.value.entity_reference: diff --git a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php index 07ec8cd..a91e484 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/SelectionBase.php @@ -118,6 +118,12 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta 'auto_create' => FALSE, ); + // Add the plugin ID to enable static configuration schema traversal. + $form['plugin_id'] = array( + '#type' => 'value', + '#value' => $this->getPluginId(), + ); + if ($entity_type->hasKey('bundle')) { $bundle_options = array(); foreach ($bundles as $bundle_name => $bundle_info) { 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 ec291fa..9648db9 100644 --- a/core/modules/entity_reference/config/schema/entity_reference.schema.yml +++ b/core/modules/entity_reference/config/schema/entity_reference.schema.yml @@ -1,9 +1,12 @@ # Schema for the configuration files of the Entity Reference module. -entity_reference.default.handler_settings: +entity_reference.handler_settings: type: mapping label: 'View handler settings' mapping: + plugin_id: + type: string + label: 'Entity reference selection plugin ID' target_bundles: type: sequence label: 'types' @@ -20,19 +23,9 @@ entity_reference.default.handler_settings: direction: type: string label: 'Sort direction' - filter: - type: mapping - label: 'Filter settings' - mapping: - type: - type: string - label: 'Filter by' - role: - type: sequence - label: 'Restrict to the selected roles' - sequence: - - type: string - label: 'Role' auto_create: type: boolean label: 'Create referenced entities if they don''t already exist' + +entity_reference.handler_settings.*: + type: entity_reference.handler_settings diff --git a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php index 5e98176..76a59b4 100644 --- a/core/modules/entity_reference/src/Tests/Views/SelectionTest.php +++ b/core/modules/entity_reference/src/Tests/Views/SelectionTest.php @@ -67,6 +67,7 @@ public function setUp() { 'settings' => array( 'handler' => 'views', 'handler_settings' => array( + 'plugin_id' => 'views', 'view' => array( 'view_name' => 'test_entity_reference', 'display_name' => 'entity_reference_1', diff --git a/core/modules/user/config/schema/user.schema.yml b/core/modules/user/config/schema/user.schema.yml index 772deea..279521c 100644 --- a/core/modules/user/config/schema/user.schema.yml +++ b/core/modules/user/config/schema/user.schema.yml @@ -174,3 +174,20 @@ condition.plugin.user_role: type: sequence sequence: - type: string + +entity_reference.handler_settings.default:user: + type: entity_reference.handler_settings + mapping: + filter: + type: mapping + label: 'Filter settings' + mapping: + type: + type: string + label: 'Filter by' + role: + type: sequence + label: 'Restrict to the selected roles' + sequence: + - type: string + label: 'Role' diff --git a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php index 8d2e701..33c5330 100644 --- a/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php +++ b/core/modules/user/src/Plugin/EntityReferenceSelection/UserSelection.php @@ -122,6 +122,12 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta ); } + // Add the plugin ID to enable static configuration schema traversal. + $form['plugin_id'] = array( + '#type' => 'value', + '#value' => $this->getPluginId(), + ); + $form += parent::buildConfigurationForm($form, $form_state); return $form; diff --git a/core/modules/user/src/Tests/UserEntityReferenceTest.php b/core/modules/user/src/Tests/UserEntityReferenceTest.php index c62b69b..0652253 100644 --- a/core/modules/user/src/Tests/UserEntityReferenceTest.php +++ b/core/modules/user/src/Tests/UserEntityReferenceTest.php @@ -68,6 +68,7 @@ function testUserSelectionByRole() { $this->role1->id() => $this->role1->id(), $this->role2->id() => 0, ); + $field_definition->settings['handler_settings']['plugin_id'] = 'default:user'; $field_definition->settings['handler_settings']['filter']['type'] = 'role'; $field_definition->save(); diff --git a/core/modules/views/config/schema/views.entity_reference.schema.yml b/core/modules/views/config/schema/views.entity_reference.schema.yml index 3067041..51704a1 100644 --- a/core/modules/views/config/schema/views.entity_reference.schema.yml +++ b/core/modules/views/config/schema/views.entity_reference.schema.yml @@ -1,9 +1,12 @@ # Schema for the views entity reference selection plugins. -entity_reference.views.handler_settings: +entity_reference.handler_settings.views: type: mapping label: 'View handler settings' mapping: + plugin_id: + type: string + label: 'Entity reference selection plugin ID' view: type: mapping label: 'View used to select the entities' diff --git a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php index 4c0d889..b05fea7 100644 --- a/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php @@ -127,6 +127,11 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta )) . '

', ); } + // Add the plugin ID to enable static configuration schema traversal. + $form['plugin_id'] = array( + '#type' => 'value', + '#value' => $this->getPluginId(), + ); return $form; }