function StatisticsPopularBlock::nodeTitleList
Same name in other branches
- 8.9.x core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::nodeTitleList()
- 10 core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::nodeTitleList()
- 11.x core/modules/statistics/src/Plugin/Block/StatisticsPopularBlock.php \Drupal\statistics\Plugin\Block\StatisticsPopularBlock::nodeTitleList()
Generates the ordered array of node links for build().
Parameters
int[] $nids: An ordered array of node ids.
string $title: The title for the list.
Return value
array A render array for the list.
1 call to StatisticsPopularBlock::nodeTitleList()
- StatisticsPopularBlock::build in core/
modules/ statistics/ src/ Plugin/ Block/ StatisticsPopularBlock.php - Builds and returns the renderable array for this block plugin.
File
-
core/
modules/ statistics/ src/ Plugin/ Block/ StatisticsPopularBlock.php, line 193
Class
- StatisticsPopularBlock
- Provides a 'Popular content' block.
Namespace
Drupal\statistics\Plugin\BlockCode
protected function nodeTitleList(array $nids, $title) {
$nodes = $this->entityTypeManager
->getStorage('node')
->loadMultiple($nids);
$items = [];
foreach ($nids as $nid) {
$node = $this->entityRepository
->getTranslationFromContext($nodes[$nid]);
$item = $node->toLink()
->toRenderable();
$this->renderer
->addCacheableDependency($item, $node);
$items[] = $item;
}
return [
'#theme' => 'item_list__node',
'#items' => $items,
'#title' => $title,
'#cache' => [
'tags' => $this->entityTypeManager
->getDefinition('node')
->getListCacheTags(),
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.