You are here

public function TaxonomyMenuMenuLink::getTitle in Taxonomy menu 8.3

Returns the localized title to be shown for this link.

Return value

string The title of the menu link.

Overrides MenuLinkInterface::getTitle

File

src/Plugin/Menu/TaxonomyMenuMenuLink.php, line 93

Class

TaxonomyMenuMenuLink
Defines menu links provided by taxonomy menu.

Namespace

Drupal\taxonomy_menu\Plugin\Menu

Code

public function getTitle() {

  /* @var $link \Drupal\taxonomy\Entity\Term. */
  $link = $this->entityTypeManager
    ->getStorage('taxonomy_term')
    ->load($this->pluginDefinition['metadata']['taxonomy_term_id']);
  $language = \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId();
  if (!empty($link) && $link
    ->hasTranslation($language)) {
    $translation = $link
      ->getTranslation($language);
    return $translation
      ->label();
  }
  else {
    if ($link) {
      return $link
        ->label();
    }
  }
  return NULL;
}