private function HierarchicalTaxonomyMenuBlock::getLinkFromTid in Hierarchical Taxonomy Menu 8
Gets term url.
1 call to HierarchicalTaxonomyMenuBlock::getLinkFromTid()
- HierarchicalTaxonomyMenuBlock::build in src/
Plugin/ Block/ HierarchicalTaxonomyMenuBlock.php - Builds and returns the renderable array for this block plugin.
File
- src/
Plugin/ Block/ HierarchicalTaxonomyMenuBlock.php, line 706
Class
- HierarchicalTaxonomyMenuBlock
- Provides a 'HierarchicalTaxonomyMenuBlock' block.
Namespace
Drupal\hierarchical_taxonomy_menu\Plugin\BlockCode
private function getLinkFromTid($tid) {
$language = $this->languageManager
->getCurrentLanguage()
->getId();
if (isset(self::$terms[$tid])) {
$term = self::$terms[$tid];
}
else {
$term = $this->entityTypeManager
->getStorage('taxonomy_term')
->load($tid);
self::$terms[$tid] = $term;
}
$translation_languages = $term
->getTranslationLanguages();
if (isset($translation_languages[$language])) {
/** @var \Drupal\taxonomy\TermInterface $term_translated */
$term_translated = $term
->getTranslation($language);
return $term_translated
->toUrl();
}
return $term
->toUrl();
}