public function SelectionPluginManager::getSelectionHandler in Drupal 9
Same name and namespace in other branches
- 8 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\EntityReferenceSelectionCode
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);
}