You are here

private function CloudBuilder::displayNodeLinkWeight in TagCloud 8

Same name and namespace in other branches
  1. 2.0.x src/CloudBuilder.php \Drupal\tagclouds\CloudBuilder::displayNodeLinkWeight()
  2. 1.0.x src/CloudBuilder.php \Drupal\tagclouds\CloudBuilder::displayNodeLinkWeight()
1 call to CloudBuilder::displayNodeLinkWeight()
CloudBuilder::build in src/CloudBuilder.php
Returns a render array for the tags.

File

src/CloudBuilder.php, line 95

Class

CloudBuilder
Class CloudBuilder.

Namespace

Drupal\tagclouds

Code

private function displayNodeLinkWeight($name, $tid, $nid, $weight, $description) {
  if ($term = Term::load($tid) && ($node = Node::load($nid))) {
    $uri = $node
      ->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;
  }
}