public function DefaultSelection::getReferenceableEntities in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection::getReferenceableEntities()
Gets the list of referenceable entities.
Return value
array A nested array of entities, the first level is keyed by the entity bundle, which contains an array of entity labels (escaped), keyed by the entity ID.
Overrides SelectionInterface::getReferenceableEntities
2 calls to DefaultSelection::getReferenceableEntities()
- PhpSelection::getReferenceableEntities in core/
lib/ Drupal/ Core/ Entity/ Plugin/ EntityReferenceSelection/ PhpSelection.php - Gets the list of referenceable entities.
- TermSelection::getReferenceableEntities in core/
modules/ taxonomy/ src/ Plugin/ EntityReferenceSelection/ TermSelection.php - Gets the list of referenceable entities.
2 methods override DefaultSelection::getReferenceableEntities()
- PhpSelection::getReferenceableEntities in core/
lib/ Drupal/ Core/ Entity/ Plugin/ EntityReferenceSelection/ PhpSelection.php - Gets the list of referenceable entities.
- TermSelection::getReferenceableEntities in core/
modules/ taxonomy/ src/ Plugin/ EntityReferenceSelection/ TermSelection.php - Gets the list of referenceable entities.
File
- core/
lib/ Drupal/ Core/ Entity/ Plugin/ EntityReferenceSelection/ DefaultSelection.php, line 242 - Contains \Drupal\Core\Entity\Plugin\EntityReferenceSelection\DefaultSelection.
Class
- DefaultSelection
- Default plugin implementation of the Entity Reference Selection plugin.
Namespace
Drupal\Core\Entity\Plugin\EntityReferenceSelectionCode
public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) {
$target_type = $this->configuration['target_type'];
$query = $this
->buildEntityQuery($match, $match_operator);
if ($limit > 0) {
$query
->range(0, $limit);
}
$result = $query
->execute();
if (empty($result)) {
return array();
}
$options = array();
$entities = entity_load_multiple($target_type, $result);
foreach ($entities as $entity_id => $entity) {
$bundle = $entity
->bundle();
$options[$bundle][$entity_id] = Html::escape($entity
->label());
}
return $options;
}