You are here

class SocialSearchBreadcrumbBuilder in Open Social 10.1.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  2. 8 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  3. 8.2 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  4. 8.3 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  5. 8.4 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  6. 8.5 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  7. 8.6 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  8. 8.7 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  9. 8.8 modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  10. 10.3.x modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  11. 10.0.x modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder
  12. 10.2.x modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php \Drupal\social_search\SocialSearchBreadcrumbBuilder

Class to define the search breadcrumb builder.

Hierarchy

Expanded class hierarchy of SocialSearchBreadcrumbBuilder

1 string reference to 'SocialSearchBreadcrumbBuilder'
social_search.services.yml in modules/social_features/social_search/social_search.services.yml
modules/social_features/social_search/social_search.services.yml
1 service uses SocialSearchBreadcrumbBuilder
social_search.breadcrumb in modules/social_features/social_search/social_search.services.yml
Drupal\social_search\SocialSearchBreadcrumbBuilder

File

modules/social_features/social_search/src/SocialSearchBreadcrumbBuilder.php, line 14

Namespace

Drupal\social_search
View source
class SocialSearchBreadcrumbBuilder implements BreadcrumbBuilderInterface {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    $search_routes = [
      'view.search_all.page',
      'view.search_all.page_no_value',
      'view.search_content.page',
      'view.search_content.page_no_value',
      'view.search_users.page',
      'view.search_users.page_no_value',
      'view.search_groups.page',
      'view.search_groups.page_no_value',
    ];
    return in_array($route_match
      ->getRouteName(), $search_routes);
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SocialSearchBreadcrumbBuilder::applies public function Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface::applies
SocialSearchBreadcrumbBuilder::build public function Builds the breadcrumb. Overrides BreadcrumbBuilderInterface::build
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.