function apachesolr_entityreference_facet_map_callback in Apache Solr Search 8
Same name and namespace in other branches
- 7 apachesolr.module \apachesolr_entityreference_facet_map_callback()
Mapping callback for entity references.
1 string reference to 'apachesolr_entityreference_facet_map_callback'
- entityreference_apachesolr_field_mappings in ./
apachesolr.module - Implements hook_apachesolr_field_mappings() on behalf of EntityReferences (entityreference)
File
- ./
apachesolr.module, line 2324 - Integration with the Apache Solr search application.
Code
function apachesolr_entityreference_facet_map_callback(array $values, array $options) {
$map = array();
// Gathers entity ids so we can load multiple entities at a time.
$entity_ids = array();
foreach ($values as $value) {
list($entity_type, $id) = explode(':', $value);
$entity_ids[$entity_type][] = $id;
}
// Loads and maps entities.
foreach ($entity_ids as $entity_type => $ids) {
$entities = entity_load($entity_type, $ids);
foreach ($entities as $id => $entity) {
$key = $entity_type . ':' . $id;
$map[$key] = entity_label($entity_type, $entity);
}
}
return $map;
}