Overrides \Drupal\Component\Plugin\PluginManagerBase::getInstance().
Overrides PluginManagerBase::getInstance
public function getInstance(array $options) {
$selection_handler = $options['instance']['settings']['handler'];
$target_entity_type = $options['field']['settings']['target_type'];
// Get all available selection plugins for this entity type.
$selection_handler_groups = $this
->getSelectionGroups($target_entity_type);
// Sort the selection plugins by weight and select the best match.
uasort($selection_handler_groups[$selection_handler], 'drupal_sort_weight');
end($selection_handler_groups[$selection_handler]);
$plugin_id = key($selection_handler_groups[$selection_handler]);
return $this
->createInstance($plugin_id, $options);
}