SelectionPluginManagerInterface.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Drupal\Core\Entity\EntityReferenceSelection;
  3. use Drupal\Component\Plugin\PluginManagerInterface;
  4. use Drupal\Core\Entity\EntityInterface;
  5. use Drupal\Core\Field\FieldDefinitionInterface;
  6. /**
  7. * Defines an interface for the entity reference selection plugin manager.
  8. */
  9. interface SelectionPluginManagerInterface extends PluginManagerInterface {
  10. /**
  11. * Gets the plugin ID for a given target entity type and base plugin ID.
  12. *
  13. * @param string $target_type
  14. * The target entity type.
  15. * @param string $base_plugin_id
  16. * The base plugin ID (e.g. 'default' or 'views').
  17. *
  18. * @return string
  19. * The plugin ID.
  20. */
  21. public function getPluginId($target_type, $base_plugin_id);
  22. /**
  23. * Gets the selection plugins that can reference a specific entity type.
  24. *
  25. * @param string $entity_type_id
  26. * A Drupal entity type ID.
  27. *
  28. * @return array
  29. * An array of selection plugins grouped by selection group.
  30. */
  31. public function getSelectionGroups($entity_type_id);
  32. /**
  33. * Gets the selection handler for a given entity_reference field.
  34. *
  35. * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
  36. * The field definition for the operation.
  37. * @param \Drupal\Core\Entity\EntityInterface $entity
  38. * (optional) The entity for the operation. Defaults to NULL.
  39. *
  40. * @return \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface
  41. * The selection plugin.
  42. */
  43. public function getSelectionHandler(FieldDefinitionInterface $field_definition, EntityInterface $entity = NULL);
  44. }