public function SelectionBase::getReferencableEntities in Entity reference 8
Implements EntityReferenceHandler::getReferencableEntities().
Overrides SelectionInterface::getReferencableEntities
1 call to SelectionBase::getReferencableEntities()
- SelectionBase::validateAutocompleteInput in lib/
Drupal/ entityreference/ Plugin/ entityreference/ selection/ SelectionBase.php - Implements EntityReferenceHandler::validateAutocompleteInput().
File
- lib/
Drupal/ entityreference/ Plugin/ entityreference/ selection/ SelectionBase.php, line 157 - Definition of Drupal\entityreference\Plugin\entityreference\selection\SelectionBase.
Class
- SelectionBase
- Plugin implementation of the 'selection' entityreference.
Namespace
Drupal\entityreference\Plugin\entityreference\selectionCode
public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
$entity_type = $this->field['settings']['target_type'];
$query = $this
->buildEntityFieldQuery($match, $match_operator);
if ($limit > 0) {
$query
->range(0, $limit);
}
$result = $query
->execute();
if (empty($result[$entity_type])) {
return array();
}
$options = array();
$entities = entity_load_multiple($entity_type, array_keys($result[$entity_type]));
foreach ($entities as $entity_id => $entity) {
$options[$entity_id] = check_plain($entity
->label());
}
return $options;
}