You are here

public function EntityReference_SelectionHandler_Generic::getReferencableEntities in Entity reference 7

Implements EntityReferenceHandler::getReferencableEntities().

Overrides EntityReference_SelectionHandler::getReferencableEntities

2 calls to EntityReference_SelectionHandler_Generic::getReferencableEntities()
EntityReference_SelectionHandler_Generic::validateAutocompleteInput in plugins/selection/EntityReference_SelectionHandler_Generic.class.php
Implements EntityReferenceHandler::validateAutocompleteInput().
EntityReference_SelectionHandler_Generic_taxonomy_term::getReferencableEntities in plugins/selection/EntityReference_SelectionHandler_Generic.class.php
Implements EntityReferenceHandler::getReferencableEntities().
1 method overrides EntityReference_SelectionHandler_Generic::getReferencableEntities()
EntityReference_SelectionHandler_Generic_taxonomy_term::getReferencableEntities in plugins/selection/EntityReference_SelectionHandler_Generic.class.php
Implements EntityReferenceHandler::getReferencableEntities().

File

plugins/selection/EntityReference_SelectionHandler_Generic.class.php, line 158

Class

EntityReference_SelectionHandler_Generic
A generic Entity handler.

Code

public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
  $options = array();
  $entity_type = $this->field['settings']['target_type'];
  $query = $this
    ->buildEntityFieldQuery($match, $match_operator);
  if ($limit > 0) {
    $query
      ->range(0, $limit);
  }
  $results = $query
    ->execute();
  if (!empty($results[$entity_type])) {
    $entities = entity_load($entity_type, array_keys($results[$entity_type]));
    foreach ($entities as $entity_id => $entity) {
      list(, , $bundle) = entity_extract_ids($entity_type, $entity);
      $options[$bundle][$entity_id] = check_plain($this
        ->getLabel($entity));
    }
  }
  return $options;
}