You are here

public function GroupBreadcrumbBuilder::build in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Breadcrumb/GroupBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\GroupBreadcrumbBuilder::build()
  2. 3.x 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\Breadcrumb

Code

public function build(RouteMatchInterface $route_match) {
  $links = array(
    Link::createFromRoute($this
      ->t('Home'), '<front>'),
  );

  /** @var \Drupal\rng\GroupInterface $group */
  $group = $route_match
    ->getParameter('registration_group');
  if ($event = $group
    ->getEvent()) {
    $links[] = new Link($event
      ->label(), $event
      ->urlInfo());
  }
  $breadcrumb = new Breadcrumb();
  return $breadcrumb
    ->setLinks($links)
    ->addCacheContexts([
    'route.name',
  ]);
}