public function ForumNodeBreadcrumbBuilder::build in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder::build()
Builds the breadcrumb.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
Return value
\Drupal\Core\Breadcrumb\Breadcrumb A breadcrumb.
Overrides ForumBreadcrumbBuilderBase::build
File
- core/
modules/ forum/ src/ Breadcrumb/ ForumNodeBreadcrumbBuilder.php, line 30 - Contains \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder.
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->forumManager
->getParents($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', array(
'taxonomy_term' => $parent
->id(),
)));
}
}
return $breadcrumb;
}