You are here

interface EntityReference_SelectionHandler in Entity reference 7

@file Abstraction of the selection logic of an entity reference field.

Implementations that wish to provide an implementation of this should register it using CTools' plugin system.

Hierarchy

Expanded class hierarchy of EntityReference_SelectionHandler

All classes that implement EntityReference_SelectionHandler

File

plugins/selection/abstract.inc, line 10
Abstraction of the selection logic of an entity reference field.

View source
interface EntityReference_SelectionHandler {

  /**
   * Factory function: create a new instance of this handler for a given field.
   *
   * @param $field
   *   A field datastructure.
   * @return EntityReferenceHandler
   */
  public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL);

  /**
   * Return a list of referencable entities.
   *
   * @return
   *   A nested array of entities, the first level is keyed by the
   *   entity bundle, which contains an array of entity labels (safe HTML),
   *   keyed by the entity ID.
   */
  public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0);

  /**
   * Count entities that are referencable by a given field.
   */
  public function countReferencableEntities($match = NULL, $match_operator = 'CONTAINS');

  /**
   * Validate that entities can be referenced by this field.
   *
   * @return
   *   An array of entity ids that are valid.
   */
  public function validateReferencableEntities(array $ids);

  /**
   * Validate Input from autocomplete widget that has no Id.
   *
   * @see _entityreference_autocomplete_validate()
   *
   * @param $input
   * 	 Single string from autocomplete widget.
   * @param $element
   *   The form element to set a form error.
   * @return
   *   Value of a matching entity id, or NULL if none.
   */
  public function validateAutocompleteInput($input, &$element, &$form_state, $form);

  /**
   * Give the handler a chance to alter the SelectQuery generated by EntityFieldQuery.
   */
  public function entityFieldQueryAlter(SelectQueryInterface $query);

  /**
   * Return the label of a given entity.
   */
  public function getLabel($entity);

  /**
   * Generate a settings form for this handler.
   */
  public static function settingsForm($field, $instance);

}

Members

Namesort descending Modifiers Type Description Overrides
EntityReference_SelectionHandler::countReferencableEntities public function Count entities that are referencable by a given field. 3
EntityReference_SelectionHandler::entityFieldQueryAlter public function Give the handler a chance to alter the SelectQuery generated by EntityFieldQuery. 3
EntityReference_SelectionHandler::getInstance public static function Factory function: create a new instance of this handler for a given field. 3
EntityReference_SelectionHandler::getLabel public function Return the label of a given entity. 3
EntityReference_SelectionHandler::getReferencableEntities public function Return a list of referencable entities. 3
EntityReference_SelectionHandler::settingsForm public static function Generate a settings form for this handler. 3
EntityReference_SelectionHandler::validateAutocompleteInput public function Validate Input from autocomplete widget that has no Id. 3
EntityReference_SelectionHandler::validateReferencableEntities public function Validate that entities can be referenced by this field. 3