public function TagcloudsListVocs::listVocs in TagCloud 8
Same name and namespace in other branches
- 2.0.x src/Controller/TagcloudsListVocs.php \Drupal\tagclouds\Controller\TagcloudsListVocs::listVocs()
- 1.0.x src/Controller/TagcloudsListVocs.php \Drupal\tagclouds\Controller\TagcloudsListVocs::listVocs()
Renders a list of vocabularies.
Vocabularys are wrapped in a series of boxes, labeled by name description.
Parameters
string $tagclouds_vocs_str: A comma separated list of vocabulary ids.
Return value
array A render array.
Throws
NotFoundHttpException Thrown when any vocabulary in the list cannot be found.
1 string reference to 'TagcloudsListVocs::listVocs'
File
- src/
Controller/ TagcloudsListVocs.php, line 71
Class
- TagcloudsListVocs
- Controller routines for user routes.
Namespace
Drupal\tagclouds\ControllerCode
public function listVocs($tagclouds_vocs_str = NULL) {
$vocs = $this
->csvToArray($tagclouds_vocs_str);
if (empty($vocs)) {
throw new NotFoundHttpException();
}
$boxes = [];
foreach ($vocs as $vid) {
$vocabulary = Vocabulary::load($vid);
if ($vocabulary == FALSE) {
throw new NotFoundHttpException();
}
$config = $this
->config('tagclouds.settings');
$tags = $this->tagService
->getTags([
$vid,
], $config
->get('levels'), $config
->get('page_amount'));
$sorted_tags = $this->tagService
->sortTags($tags);
$cloud = $this->cloudBuilder
->build($sorted_tags);
if (!$cloud) {
throw new NotFoundHttpException();
}
$boxes[] = [
'#theme' => 'tagclouds_list_box',
'#vocabulary' => $vocabulary,
'#children' => $cloud,
];
}
// Wrap boxes in a div.
$output = [
'#attached' => [
'library' => 'tagclouds/clouds',
],
'#type' => 'container',
'#children' => $boxes,
'#attributes' => [
'class' => 'wrapper tagclouds',
],
];
return $output;
}