You are here

protected function Vocabulary::buildTermLink in Sitemap 8.2

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Sitemap/Vocabulary.php \Drupal\sitemap\Plugin\Sitemap\Vocabulary::buildTermLink()

Builds the taxonomy term link.

Parameters

\stdClass $term: The term object returned by TermStorage::loadTree()

Return value

string|void

1 call to Vocabulary::buildTermLink()
Vocabulary::buildSitemapTerm in src/Plugin/Sitemap/Vocabulary.php
Builds a taxonomy term item.

File

src/Plugin/Sitemap/Vocabulary.php, line 315

Class

Vocabulary
Provides a sitemap for an taxonomy vocabulary.

Namespace

Drupal\sitemap\Plugin\Sitemap

Code

protected function buildTermLink($term) {
  $vid = $this->pluginDefinition['vocabulary'];

  // @TODO: Add and test handling for Forum vs Vocab routes
  if (\Drupal::service('module_handler')
    ->moduleExists('forum') && $vid == \Drupal::config('forum.settings')
    ->get('vocabulary')) {
    return Url::fromRoute('forum.index')
      ->toString();
  }

  // Route validation will be provided on form save and config update,
  // rather than every time a link is created.
  if (isset($this->settings['term_link'])) {
    return $this
      ->buildLink($this->settings['term_link'], $term->tid);
  }
}