You are here

private function CloudBuilder::displayTermLinkWeight in TagCloud 8

Same name and namespace in other branches
  1. 2.0.x src/CloudBuilder.php \Drupal\tagclouds\CloudBuilder::displayTermLinkWeight()
  2. 1.0.x src/CloudBuilder.php \Drupal\tagclouds\CloudBuilder::displayTermLinkWeight()

Display Single Tag with Style

1 call to CloudBuilder::displayTermLinkWeight()
CloudBuilder::build in src/CloudBuilder.php
Returns a render array for the tags.

File

src/CloudBuilder.php, line 75

Class

CloudBuilder
Class CloudBuilder.

Namespace

Drupal\tagclouds

Code

private function displayTermLinkWeight($name, $tid, $weight, $description) {
  if ($term = Term::load($tid)) {
    $uri = $term
      ->urlInfo();
    $options = $uri
      ->getOptions();
    $options['attributes']['class'][] = 'tagclouds';
    $options['attributes']['class'][] = 'level' . $weight;
    $uri
      ->setOptions($options);
    $build = [
      '#type' => 'link',
      '#prefix' => '<span class="tagclouds-term">',
      '#title' => $name,
      '#url' => $uri,
      '#suffix' => '</span>',
    ];
    return $build;
  }
}