nortmas
10/13/2017 - 5:25 AM

Taxonomy

// Load tree
$tree = \Drupal::entityManager()->getStorage('taxonomy_term')->loadTree("vac_name", 0, NULL, TRUE);
// Load nodes related to the term.
$tree = \Drupal::entityManager()->getStorage('taxonomy_term')->getNodeTerms($nids, $vids);


use Drupal\taxonomy\TermInterface;
use Drupal\taxonomy\Entity\Term;
 
$term = $this->entityTypeManager->getStorage('taxonomy_term')->load($tid);
$term = Term::load($tid);
$children = $this->entityTypeManager->getStorage('taxonomy_term')->loadChildren($tid);
$tree = $this->entityTypeManager->getStorage('taxonomy_term')->loadTree($vid, 0, NULL, TRUE);
$vocabulary = $term->getVocabularyId();
$term_name = $term->getName();
$description = $term->getDescription();
$sort = $term->getWeight();

// Term get parents:
$ancestors = \Drupal::service('entity_type.manager')->getStorage("taxonomy_term")->loadAllParents($tid);


//Get term by name:
taxonomy_term_load_multiple_by_name($name, $vocabulary);