You are here

public function BusinessRulesBreadcrumb::build in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/BusinessRulesBreadcrumb.php \Drupal\business_rules\BusinessRulesBreadcrumb::build()

Builds the breadcrumb.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

Return value

\Drupal\Core\Breadcrumb\Breadcrumb A breadcrumb.

Overrides PathBasedBreadcrumbBuilder::build

File

src/BusinessRulesBreadcrumb.php, line 29

Class

BusinessRulesBreadcrumb
Adjust the breadcrumbs for the Business Rules module.

Namespace

Drupal\business_rules

Code

public function build(RouteMatchInterface $route_match) {

  /** @var \Drupal\Core\Breadcrumb\Breadcrumb $breadcrumb */
  $breadcrumb = parent::build($route_match);
  $route_name = $route_match
    ->getRouteName();
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Business Rules'), 'entity.business_rule.collection'));
  if (stristr($route_name, 'entity.business_rules_action')) {
    $breadcrumb
      ->addLink(Link::createFromRoute($this
      ->t('Actions'), 'entity.business_rules_action.collection'));
  }
  elseif (stristr($route_name, 'entity.business_rules_condition')) {
    $breadcrumb
      ->addLink(Link::createFromRoute($this
      ->t('Conditions'), 'entity.business_rules_condition.collection'));
  }
  elseif (stristr($route_name, 'entity.business_rules_variable')) {
    $breadcrumb
      ->addLink(Link::createFromRoute($this
      ->t('Variables'), 'entity.business_rules_variable.collection'));
  }
  return $breadcrumb;
}