public ForumNodeBreadcrumbBuilder::build(RouteMatchInterface $route_match)
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 25
Class
- ForumNodeBreadcrumbBuilder
- Breadcrumb builder for forum nodes.
Namespace
Drupal\forum\Breadcrumb
Code
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; }
Please login to continue.