You are here

public function SocialSearchBreadcrumbBuilder::build in Open Social 10.0.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  2. 8 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  3. 8.2 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  4. 8.3 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  5. 8.4 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  6. 8.5 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  7. 8.6 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  8. 8.7 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  9. 8.8 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  10. 10.3.x modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  11. 10.1.x modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::build()
  12. 10.2.x modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder::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/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php, line 37

Class

SocialSearchBreadcrumbBuilder
Class to define the search breadcrumb builder.

Namespace

Drupal\social_search

Code

public function build(RouteMatchInterface $route_match) {
  $breadcrumb = new Breadcrumb();
  switch ($route_match
    ->getRouteName()) {
    case 'view.search_content.page':
    case 'view.search_content.page_no_value':
    case 'view.search_users.page':
    case 'view.search_users.page_no_value':
    case 'view.search_groups.page':
    case 'view.search_groups.page_no_value':
    case 'view.search_all.page':
    case 'view.search_all.page_no_value':

      // No value because of duplicate words.
      break;
    default:
      $page_title = $this
        ->t('Search');
      $breadcrumb
        ->addLink(Link::createFromRoute($page_title, '<none>'));
  }
  $breadcrumb
    ->addLink(Link::createFromRoute($this
    ->t('Home'), '<front>'));

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