SelectionInterface.php 1.55 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\Core\Entity\EntityReferenceSelection\SelectionInterface.
6 7
 */

8
namespace Drupal\Core\Entity\EntityReferenceSelection;
9 10

use Drupal\Core\Database\Query\SelectInterface;
11
use Drupal\Core\Plugin\PluginFormInterface;
12 13

/**
14
 * Interface definition for Entity Reference Selection plugins.
15
 *
16 17
 * @see \Drupal\Core\Entity\EntityReferenceSelection\SelectionPluginManager
 * @see \Drupal\Core\Entity\Annotation\EntityReferenceSelection
18
 * @see plugin_api
19
 */
20
interface SelectionInterface extends PluginFormInterface {
21 22

  /**
23
   * Gets the list of referenceable entities.
24 25
   *
   * @return array
26
   *   A nested array of entities, the first level is keyed by the
27
   *   entity bundle, which contains an array of entity labels (escaped),
28
   *   keyed by the entity ID.
29
   */
30
  public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);
31 32

  /**
33
   * Counts entities that are referenceable by a given field.
34 35
   *
   * @return int
36
   *   The number of referenceable entities.
37
   */
38
  public function countReferenceableEntities($match = NULL, $match_operator = 'CONTAINS');
39 40 41 42 43 44 45

  /**
   * Validates that entities can be referenced by this field.
   *
   * @return array
   *   An array of valid entity IDs.
   */
46
  public function validateReferenceableEntities(array $ids);
47 48 49 50 51 52 53 54 55 56

  /**
   * Allows the selection to alter the SelectQuery generated by EntityFieldQuery.
   *
   * @param \Drupal\Core\Database\Query\SelectInterface $query
   *   A Select Query object.
   */
  public function entityQueryAlter(SelectInterface $query);

}