1 EntityReferenceSelectionHandlerGeneric.inc | public EntityReferenceSelectionHandlerGeneric::getReferencableEntities($match = '', $match_operator = 'CONTAINS', $limit = 0) |
Implements EntityReferenceHandler::getReferencableEntities().
Overrides EntityReferenceSelectionHandlerInterface::getReferencableEntities
File
- core/
modules/ entityreference/ plugins/ selection/ EntityReferenceSelectionHandlerGeneric.inc, line 177 - Generic Entity handler.
Class
- EntityReferenceSelectionHandlerGeneric
- @file Generic Entity handler.
Code
public function getReferencableEntities($match = '', $match_operator = 'CONTAINS', $limit = 0) {
$options = array();
$entity_type = $this->field['settings']['target_type'];
if (is_null($match)) {
$match = '';
}
// Remove escape formatting.
$match = trim(str_replace('""', '"', $match));
$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;
}