public function SelectionPluginManager::getInstance

Overrides \Drupal\Component\Plugin\PluginManagerBase::getInstance().

Overrides PluginManagerBase::getInstance

File

drupal/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Type/SelectionPluginManager.php, line 52
Contains \Drupal\entity_reference\Plugin\Type\SelectionPluginManager.

Class

SelectionPluginManager
Plugin type manager for the Entity Reference Selection plugin.

Namespace

Drupal\entity_reference\Plugin\Type

Code

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);
}