function SelectionPluginManager::getSelectionHandler

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getSelectionHandler()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getSelectionHandler()
  3. 11.x core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager::getSelectionHandler()

Gets the selection handler for a given entity_reference field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition for the operation.

\Drupal\Core\Entity\EntityInterface $entity: (optional) The entity for the operation. Defaults to NULL.

Return value

\Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface The selection plugin.

Overrides SelectionPluginManagerInterface::getSelectionHandler

File

core/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginManager.php, line 94

Class

SelectionPluginManager
Plugin type manager for Entity Reference Selection plugins.

Namespace

Drupal\Core\Entity\EntityReferenceSelection

Code

public function getSelectionHandler(FieldDefinitionInterface $field_definition, ?EntityInterface $entity = NULL) {
  $options = $field_definition->getSetting('handler_settings') ?: [];
  $options += [
    'target_type' => $field_definition->getFieldStorageDefinition()
      ->getSetting('target_type'),
    'handler' => $field_definition->getSetting('handler'),
    'entity' => $entity,
  ];
  return $this->getInstance($options);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.