You are here

function apigee_edge_teams_system_breadcrumb_alter in Apigee Edge 8

Implements hook_system_breadcrumb_alter().

File

modules/apigee_edge_teams/apigee_edge_teams.module, line 170
Copyright 2018 Google Inc.

Code

function apigee_edge_teams_system_breadcrumb_alter(Breadcrumb &$breadcrumb, RouteMatchInterface $route_match, array $context) {
  if ($route_match
    ->getRouteName() === 'entity.team.add_form') {
    $team_entity_def = \Drupal::entityTypeManager()
      ->getDefinition('team');
    $breadcrumb
      ->addLink(Link::createFromRoute($team_entity_def
      ->getPluralLabel(), 'entity.team.collection'));
  }
  elseif ($route_match
    ->getRouteName() === 'entity.team.add_members') {

    /** @var \Drupal\apigee_edge_teams\Entity\TeamInterface $team */
    $team = $route_match
      ->getParameter('team');
    $breadcrumb
      ->addLink($team
      ->toLink(t('Members'), 'members'));
  }
  elseif ($route_match
    ->getRouteName() === 'entity.team_app.add_form_for_team') {
    $team_app_entity_def = \Drupal::entityTypeManager()
      ->getDefinition('team_app');

    /** @var \Drupal\apigee_edge_teams\Entity\TeamInterface $team */
    $team = $route_match
      ->getParameter('team');
    $breadcrumb
      ->addLink(Link::createFromRoute($team_app_entity_def
      ->getPluralLabel(), 'entity.team_app.collection_by_team', [
      'team' => $team
        ->id(),
    ]));
  }
}