public function TaxonomySynonymsBehavior::extractSynonyms in Synonyms 7
Extract synonyms from an entity within a specific behavior implementation.
Parameters
object $entity: Entity from which to extract synonyms
string $langcode: Language code for which to extract synonyms from the entity, if one is known
Return value
array Array of synonyms extracted from $entity Array of synonyms extracted from $entity
Overrides SynonymsBehavior::extractSynonyms
File
- synonyms_provider_field/
includes/ TaxonomySynonymsBehavior.class.inc, line 13 - Enables Taxonomy Term Reference field type to be source of synonyms.
Class
- TaxonomySynonymsBehavior
- Definition of TaxonomySynonymsBehavior class.
Code
public function extractSynonyms($entity, $langcode = NULL) {
$synonyms = array();
$terms = array();
foreach ($this
->entityItems($entity, $langcode) as $item) {
$terms[] = $item['tid'];
}
$terms = taxonomy_term_load_multiple($terms);
foreach ($terms as $term) {
$synonyms[] = entity_label('taxonomy_term', $term);
}
return $synonyms;
}