You are here

function LinkitSearchPluginTaxonomy_term::fetchResults in Linkit 7.3

Overrides LinkitSearchPluginEntity::fetchResults().

Overrides LinkitSearchPluginEntity::fetchResults

File

plugins/linkit_search/taxonomy_term.class.php, line 52
Define Linkit term search plugin class.

Class

LinkitSearchPluginTaxonomy_term
Reprecents a Linkit term search plugin.

Code

function fetchResults($search_string) {

  // The term entity doesn't use the entity keys bundle definition, its using
  // the vid instead, so lets 'translate' the bundle names to vids.
  if (isset($this->entity_key_bundle) && isset($this->conf['bundles'])) {
    $bundles = array_filter($this->conf['bundles']);

    // Get all vocabularies.
    $vocabularies = taxonomy_vocabulary_get_names();

    // Temp storage for values.
    $tmp_bundles = array();
    foreach ($bundles as $bundle) {
      $tmp_bundles[] = $vocabularies[$bundle]->{$this->entity_key_bundle};
    }

    // Assign the new values as the bundles.
    $this->conf['bundles'] = $tmp_bundles;
  }

  // Call the parent.
  return parent::fetchResults($search_string);
}