You are here

function apachesolr_userreference_indexing_callback in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr.index.inc \apachesolr_userreference_indexing_callback()
  2. 7 apachesolr.index.inc \apachesolr_userreference_indexing_callback()

Indexing callback for the user_reference module by the references module

1 string reference to 'apachesolr_userreference_indexing_callback'
userreference_apachesolr_field_mappings in ./apachesolr.module
Implements hook_apachesolr_field_mappings() on behalf of References (user_reference).

File

./apachesolr.index.inc, line 1207
Functions related to Apache Solr indexing operations.

Code

function apachesolr_userreference_indexing_callback($entity, $field_name, $index_key, $field_info) {
  $fields = array();
  if (!empty($entity->{$field_name})) {
    $index_key = apachesolr_index_key($field_info);
    foreach ($entity->{$field_name} as $field_references) {
      foreach ($field_references as $reference) {

        // Validate that reference is an array
        // If not, skip this element
        if (!is_array($reference)) {
          continue;
        }
        if ($index_value = isset($reference['uid']) && strlen($reference['uid']) ? $reference['uid'] : FALSE) {
          $fields[] = array(
            'key' => $index_key,
            'value' => $index_value,
          );
        }
      }
    }
  }
  return $fields;
}