public function CommentBreadcrumbBuilder::build in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/comment/src/CommentBreadcrumbBuilder.php \Drupal\comment\CommentBreadcrumbBuilder::build()
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/ comment/ src/ CommentBreadcrumbBuilder.php, line 50 - Contains \Drupal\comment\CommentBreadcrumbBuilder.
Class
- CommentBreadcrumbBuilder
- Class to define the comment breadcrumb builder.
Namespace
Drupal\commentCode
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$breadcrumb
->addCacheContexts([
'route',
]);
$breadcrumb
->addLink(Link::createFromRoute($this
->t('Home'), '<front>'));
$entity = $route_match
->getParameter('entity');
$breadcrumb
->addLink(new Link($entity
->label(), $entity
->urlInfo()));
$breadcrumb
->addCacheableDependency($entity);
if (($pid = $route_match
->getParameter('pid')) && ($comment = $this->storage
->load($pid))) {
/** @var \Drupal\comment\CommentInterface $comment */
$breadcrumb
->addCacheableDependency($comment);
// Display link to parent comment.
// @todo Clean-up permalink in https://www.drupal.org/node/2198041
$breadcrumb
->addLink(new Link($comment
->getSubject(), $comment
->urlInfo()));
}
return $breadcrumb;
}