ForumBreadcrumbBuilderBase::build

public ForumBreadcrumbBuilderBase::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 BreadcrumbBuilderInterface::build

File

core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php, line 67

Class

ForumBreadcrumbBuilderBase
Provides a forum breadcrumb base class.

Namespace

Drupal\forum\Breadcrumb

Code

public function build(RouteMatchInterface $route_match) {
  $breadcrumb = new Breadcrumb();
  $breadcrumb->addCacheContexts(['route']);

  $links[] = Link::createFromRoute($this->t('Home'), '<front>');

  $vocabulary = $this->entityManager
    ->getStorage('taxonomy_vocabulary')
    ->load($this->config->get('vocabulary'));
  $breadcrumb->addCacheableDependency($vocabulary);
  $links[] = Link::createFromRoute($vocabulary->label(), 'forum.index');

  return $breadcrumb->setLinks($links);
}
doc_Drupal
2016-10-29 09:16:58
Comments
Leave a Comment

Please login to continue.