You are here

public function SelectionPluginManager::getSelectionHandler in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 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 99
Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager.

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 = array(
    'target_type' => $field_definition
      ->getFieldStorageDefinition()
      ->getSetting('target_type'),
    'handler' => $field_definition
      ->getSetting('handler'),
    'handler_settings' => $field_definition
      ->getSetting('handler_settings') ?: array(),
    'entity' => $entity,
  );
  return $this
    ->getInstance($options);
}