function ForumNodeBreadcrumbBuilder::build
Same name in other branches
- 8.9.x core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder::build()
- 10 core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder::build()
- 11.x core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder::build()
Overrides ForumBreadcrumbBuilderBase::build
File
-
core/
modules/ forum/ src/ Breadcrumb/ ForumNodeBreadcrumbBuilder.php, line 25
Class
- ForumNodeBreadcrumbBuilder
- Breadcrumb builder for forum nodes.
Namespace
Drupal\forum\BreadcrumbCode
public function build(RouteMatchInterface $route_match) {
$breadcrumb = parent::build($route_match);
$breadcrumb->addCacheContexts([
'route',
]);
$parents = $this->termStorage
->loadAllParents($route_match->getParameter('node')->forum_tid);
if ($parents) {
$parents = array_reverse($parents);
foreach ($parents as $parent) {
$breadcrumb->addCacheableDependency($parent);
$breadcrumb->addLink(Link::createFromRoute($parent->label(), 'forum.page', [
'taxonomy_term' => $parent->id(),
]));
}
}
return $breadcrumb;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.