You are here

function synonyms_get_term_synonyms in Synonyms 7

Public function for retrieving synonyms of a taxonomy term.

You are encouraged to use synonyms_get_sanitized() or synonyms_get_raw() instead. This function soon will be removed from the source code.

Parameters

object $term: Fully loaded taxonomy term for which the synonyms are desired

Return value

array Array of synonyms, if synonyms are disabled for the taxonomy term's vocabulary, an empty array is returned. Each synonym subarray consists of the following keys:

  • value: (string) the value of a synonym as it was input by user
  • safe_value: (string) a sanitized value of a synonym

File

./synonyms.module, line 736
Provide synonyms feature for Drupal entities.

Code

function synonyms_get_term_synonyms($term) {
  if (!module_exists('taxonomy')) {
    return array();
  }
  $synonyms = array();
  $vocabulary = taxonomy_vocabulary_load($term->vid);
  $bundle = field_extract_bundle('taxonomy_term', $vocabulary);
  $behavior_implementations = synonyms_behavior_get_all_enabled('taxonomy_term', $bundle);
  foreach ($behavior_implementations as $implementation) {
    foreach ($implementation['object']
      ->extractSynonyms($term) as $synonym) {
      $synonyms[] = array(
        'value' => $synonym,
        'safe_value' => check_plain($synonym),
      );
    }
  }
  return $synonyms;
}