You are here

function apachesolr_vocab_name in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr.index.inc \apachesolr_vocab_name()
  2. 5.2 apachesolr.index.inc \apachesolr_vocab_name()
  3. 6.3 apachesolr.index.inc \apachesolr_vocab_name()
  4. 6 apachesolr.index.inc \apachesolr_vocab_name()
  5. 6.2 apachesolr.index.inc \apachesolr_vocab_name()

Helper function - return a safe (PHP identifier) vocabulary name.

Parameters

integer $vid:

Return value

string

1 call to apachesolr_vocab_name()
apachesolr_term_reference_indexing_callback in ./apachesolr.index.inc
Callback that converts term_reference field into an array

File

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

Code

function apachesolr_vocab_name($vid) {
  $names =& drupal_static(__FUNCTION__, array());
  if (!isset($names[$vid])) {
    $vocab_name = db_query('SELECT v.name FROM {taxonomy_vocabulary} v WHERE v.vid = :vid', array(
      ':vid' => $vid,
    ))
      ->fetchField();
    $names[$vid] = preg_replace('/[^a-zA-Z0-9_\\x7f-\\xff]/', '_', $vocab_name);

    // Fallback for names ending up all as '_'.
    $check = rtrim($names[$vid], '_');
    if (!$check) {
      $names[$vid] = '_' . $vid . '_';
    }
  }
  return $names[$vid];
}