You are here

public function JobItemBreadcrumbBuilder::build in Translation Management Tool 8

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/Menu/JobItemBreadcrumbBuilder.php, line 30

Class

JobItemBreadcrumbBuilder
A custom Job item breadcrumb builder.

Namespace

Drupal\tmgmt\Menu

Code

public function build(RouteMatchInterface $route_match) {
  $breadcrumb = new Breadcrumb();
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Home'), '<front>'));
  $breadcrumb
    ->addCacheContexts([
    'route',
  ]);

  /** @var JobItemInterface $job_item */
  $job_item = $route_match
    ->getParameter('tmgmt_job_item');
  $breadcrumb
    ->addCacheableDependency($job_item);

  // Add links to administration, translation, job overview and job to the
  // breadcrumb.
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Administration'), 'system.admin'));
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Translation'), 'tmgmt.admin_tmgmt'));
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Job overview'), 'view.tmgmt_job_overview.page_1'));
  $breadcrumb
    ->addLink(Link::createFromRoute($job_item
    ->getJob()
    ->label(), 'entity.tmgmt_job.canonical', array(
    'tmgmt_job' => $job_item
      ->getJobId(),
  )));
  return $breadcrumb;
}