You are here

public function WebformAccessBreadcrumbBuilder::build in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_access/src/Breadcrumb/WebformAccessBreadcrumbBuilder.php \Drupal\webform_access\Breadcrumb\WebformAccessBreadcrumbBuilder::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

modules/webform_access/src/Breadcrumb/WebformAccessBreadcrumbBuilder.php, line 73

Class

WebformAccessBreadcrumbBuilder
Provides a webform access breadcrumb builder.

Namespace

Drupal\webform_access\Breadcrumb

Code

public function build(RouteMatchInterface $route_match) {
  $breadcrumb = new Breadcrumb();
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Home'), '<front>'));
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Administration'), 'system.admin'));
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Structure'), 'system.admin_structure'));
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Webforms'), 'entity.webform.collection'));
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Access'), 'entity.webform_access_group.collection'));
  switch ($this->type) {
    case 'webform_access_group':
      $breadcrumb
        ->addLink(Link::createFromRoute($this
        ->t('Groups'), 'entity.webform_access_group.collection'));
      break;
    case 'webform_access_type':
      $breadcrumb
        ->addLink(Link::createFromRoute($this
        ->t('Types'), 'entity.webform_access_type.collection'));
      break;
  }

  // This breadcrumb builder is based on a route parameter, and hence it
  // depends on the 'route' cache context.
  $breadcrumb
    ->addCacheContexts([
    'route',
  ]);
  return $breadcrumb;
}