public function GroupBreadcrumbBuilder::build in RNG - Events and Registrations 3.x
Same name and namespace in other branches
- 8.2 src/Breadcrumb/GroupBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\GroupBreadcrumbBuilder::build()
- 8 src/Breadcrumb/GroupBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\GroupBreadcrumbBuilder::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
- src/
Breadcrumb/ GroupBreadcrumbBuilder.php, line 30
Class
- GroupBreadcrumbBuilder
- Provides a breadcrumb builder for groups.
Namespace
Drupal\rng\BreadcrumbCode
public function build(RouteMatchInterface $route_match) {
$links = [
Link::createFromRoute($this
->t('Home'), '<front>'),
];
/** @var \Drupal\rng\Entity\GroupInterface $group */
$group = $route_match
->getParameter('registration_group');
if ($event = $group
->getEvent()) {
$links[] = new Link($event
->label(), $event
->toUrl());
}
$breadcrumb = new Breadcrumb();
return $breadcrumb
->setLinks($links)
->addCacheContexts([
'route.name',
]);
}