public function SelectionPluginManager::getSelectionHandler in Dynamic Entity Reference 8
Same name and namespace in other branches
- 8.2 src/SelectionPluginManager.php \Drupal\dynamic_entity_reference\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 SelectionPluginManager::getSelectionHandler
File
- src/
SelectionPluginManager.php, line 20
Class
- SelectionPluginManager
- Plugin type manager for Dynamic Entity Reference Selection plugins.
Namespace
Drupal\dynamic_entity_referenceCode
public function getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL, $target_type = NULL) {
if ($target_type === NULL) {
return parent::getSelectionHandler($field_definition, $entity);
}
$settings = $field_definition
->getSettings();
$options = $settings[$target_type]['handler_settings'] ?? [];
$options += [
'target_type' => $target_type,
'handler' => $settings[$target_type]['handler'],
'entity' => $entity,
];
return $this
->getInstance($options);
}