You are here

public function RuleComponentBreadcrumbBuilder::build in RNG - Events and Registrations 8.2

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

Class

RuleComponentBreadcrumbBuilder
Provides a breadcrumb builder for RNG rule components.

Namespace

Drupal\rng\Breadcrumb

Code

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

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