SelectionInterface.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Drupal\Core\Entity\EntityReferenceSelection;
  3. use Drupal\Core\Database\Query\SelectInterface;
  4. use Drupal\Core\Plugin\PluginFormInterface;
  5. /**
  6. * Interface definition for Entity Reference Selection plugins.
  7. *
  8. * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
  9. * @see \Drupal\Core\Entity\Annotation\EntityReferenceSelection
  10. * @see plugin_api
  11. */
  12. interface SelectionInterface extends PluginFormInterface {
  13. /**
  14. * Gets the list of referenceable entities.
  15. *
  16. * @return array
  17. * A nested array of entities, the first level is keyed by the
  18. * entity bundle, which contains an array of entity labels (escaped),
  19. * keyed by the entity ID.
  20. */
  21. public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);
  22. /**
  23. * Counts entities that are referenceable.
  24. *
  25. * @return int
  26. * The number of referenceable entities.
  27. */
  28. public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS');
  29. /**
  30. * Validates which existing entities can be referenced.
  31. *
  32. * @return array
  33. * An array of valid entity IDs.
  34. */
  35. public function validateReferenceableEntities(array $ids);
  36. /**
  37. * Allows the selection to alter the SelectQuery generated by EntityFieldQuery.
  38. *
  39. * @param \Drupal\Core\Database\Query\SelectInterface $query
  40. * A Select Query object.
  41. */
  42. public function entityQueryAlter(SelectInterface $query);
  43. }