From now on, a custom entity reference selection handler should extend the new introduced base class \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginBase (or a successor).
Changes
Plugins extending this new base class:
- Are able to provide sane defaults by implementing the
ConfigurablePluginInterface::defaultConfiguration()method. - Are able to set or get the plugin configuration by using the
::setConfiguration()and::getConfiguration()methods (implemented fromConfigurablePluginInterface). - Should pass handler settings, previously passed in plugin configuration under
handler_settingskey, in the root of configuration. Thehandler_settingslevel/namespace was deprecated. This is true for::defaultConfiguration()but also for::setConfiguration().
Example of how the structure of plugin configuration has changed (DefaultSelection):
Before:
[
'target_type' => 'node',
'handler' => 'default',
'entity' => NULL,
'handler_settings' => [
'target_bundles' => [
'article',
],
'sort' => [
'field' => 'title',
'direction' => 'ASC',
],
'auto_create' => FALSE,
'auto_create_bundle' => NULL,
],
]
After:
[
'target_type' => 'node',
'handler' => 'default',
'entity' => NULL,
'target_bundles' => [
'article',
],
'sort' => [
'field' => 'title',
'direction' => 'ASC',
],
'auto_create' => FALSE,
'auto_create_bundle' => NULL,
]
Backward compatibility
Existing Entity reference selection handlers that are currently setting or getting the handler settings under handler_settings key, will continue to work but we recommend to move those settings under the root level of configuration, as soon as possible.
Important note
This change notice is about the selection handler plugin configuration (used to init the plugin) and not about the entity reference field configuration (stored as config entity).