You are here

function _fontyourface_get_vocabulary_term in @font-your-face 8.3

Retrieves a tid for use from taxonomy.

Parameters

string $term_value: The taxonomy term string.

string $vocabulary: The machine name of the vocabulary the term belongs to.

Return value

int The found/created taxonomy term id.

1 call to _fontyourface_get_vocabulary_term()
fontyourface_save_font in ./fontyourface.module
Saves/updates font.

File

./fontyourface.module, line 440
Contains fontyourface.module..

Code

function _fontyourface_get_vocabulary_term($term_value, $vocabulary) {
  if ($terms = taxonomy_term_load_multiple_by_name($term_value, $vocabulary)) {
    $term = reset($terms);
  }
  else {
    $term = Term::create([
      'name' => $term_value,
      'vid' => $vocabulary,
    ]);
    $term
      ->save();
  }
  return $term
    ->id();
}