You are here

public function TagcloudsPageChunk::chunk in TagCloud 8

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

Renders a list of vocabularies.

Parameters

string $tagclouds_vocs_str: A comma separated list of vocabulary ids.

Return value

array A render array.

1 string reference to 'TagcloudsPageChunk::chunk'
tagclouds.routing.yml in ./tagclouds.routing.yml
tagclouds.routing.yml

File

src/Controller/TagcloudsPageChunk.php, line 63

Class

TagcloudsPageChunk
Controller routines for user routes.

Namespace

Drupal\tagclouds\Controller

Code

public function chunk($tagclouds_vocs_str = '') {
  $vocs = $this
    ->csvToArray($tagclouds_vocs_str);
  if (empty($vocs)) {
    $query = $this
      ->entityTypeManager()
      ->getStorage('taxonomy_vocabulary')
      ->getQuery();
    $all_ids = $query
      ->execute();
    foreach (Vocabulary::loadMultiple($all_ids) as $vocabulary) {
      $vocs[] = $vocabulary
        ->id();
    }
  }
  $config = $this
    ->config('tagclouds.settings');
  $tags = $this->tagcloudTag
    ->getTags($vocs, $config
    ->get('levels'), $config
    ->get('page_amount'));
  $sorted_tags = $this->tagcloudTag
    ->sortTags($tags);
  $output = [
    '#attached' => [
      'library' => 'tagclouds/clouds',
    ],
    '#theme' => 'tagclouds_weighted',
    '#children' => $this->tagcloudsCloudBuilder
      ->build($sorted_tags),
  ];
  return $output;
}