1 EntityReferenceSelectionHandlerGeneric.inc public EntityReferenceSelectionHandlerGeneric::getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0)

Implements EntityReferenceHandler::getReferencableEntities().

Overrides EntityReferenceSelectionHandlerInterface::getReferencableEntities

File

core/modules/entityreference/plugins/selection/EntityReferenceSelectionHandlerGeneric.inc, line 170
Generic Entity handler.

Class

EntityReferenceSelectionHandlerGeneric
@file 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;
}