3 namespace Drupal\forum\Breadcrumb;
6 use Drupal\Core\Routing\RouteMatchInterface;
9 * Breadcrumb builder for forum nodes.
11 class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
16 public function applies(RouteMatchInterface $route_match) {
17 return $route_match->getRouteName() == 'entity.node.canonical'
18 && $route_match->getParameter('node')
19 && $this->forumManager->checkNodeType($route_match->getParameter('node'));
25 public function build(RouteMatchInterface $route_match) {
26 $breadcrumb = parent::build($route_match);
27 $breadcrumb->addCacheContexts(['route']);
29 $parents = $this->termStorage->loadAllParents($route_match->getParameter('node')->forum_tid);
31 $parents = array_reverse($parents);
32 foreach ($parents as $parent) {
33 $breadcrumb->addCacheableDependency($parent);
34 $breadcrumb->addLink(Link::createFromRoute($parent->label(), 'forum.page',
36 'taxonomy_term' => $parent->id(),