Interface definition for Entity Reference selection plugins.
This interface details the methods that most plugin implementations will want to override. See \Drupal\field\Plugin\Type\Selection\SelectionBaseInterface for base wrapping methods that should most likely be inherited directly from Drupal\entity_reference\Plugin\Type\Selection\SelectionBase.
Expanded class hierarchy of SelectionInterface
All classes that implement SelectionInterface
interface SelectionInterface {
/**
* Returns a list of referencable entities.
*
* @return array
* An array of referencable entities. Keys are entity IDs and
* values are (safe HTML) labels to be displayed to the user.
*/
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);
/**
* Counts entities that are referencable by a given field.
*
* @return int
* The number of referencable entities.
*/
public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS');
/**
* Validates that entities can be referenced by this field.
*
* @return array
* An array of valid entity IDs.
*/
public function validateReferencableEntities(array $ids);
/**
* Validates input from an autocomplete widget that has no ID.
*
* @param string $input
* Single string from autocomplete widget.
* @param array $element
* The form element to set a form error.
* @param boolean $strict
* Whether to trigger a form error if an element from $input (eg. an entity)
* is not found. Defaults to TRUE.
*
* @return integer|null
* Value of a matching entity ID, or NULL if none.
*
* @see \Drupal\entity_reference\Plugin\field\widget::elementValidate()
*/
public function validateAutocompleteInput($input, &$element, &$form_state, $form, $strict = TRUE);
/**
* 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);
/**
* Generates the settings form for this selection.
*
* @param array $field
* A field data structure.
* @param array $instance
* A field instance data structure.
*
* @return array
* A Form API array.
*/
public static function settingsForm(&$field, &$instance);
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
SelectionInterface:: |
public | function | Counts entities that are referencable by a given field. | 3 |
SelectionInterface:: |
public | function | Allows the selection to alter the SelectQuery generated by EntityFieldQuery. | 3 |
SelectionInterface:: |
public | function | Returns a list of referencable entities. | 3 |
SelectionInterface:: |
public static | function | Generates the settings form for this selection. | 3 |
SelectionInterface:: |
public | function | Validates input from an autocomplete widget that has no ID. | 3 |
SelectionInterface:: |
public | function | Validates that entities can be referenced by this field. | 3 |