class ForumListingBreadcrumbBuilder
Provides a breadcrumb builder base class for forum listing pages.
Hierarchy
- class \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase implements \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait- class \Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder extends \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase
 
Expanded class hierarchy of ForumListingBreadcrumbBuilder
1 file declares its use of ForumListingBreadcrumbBuilder
- ForumListingBreadcrumbBuilderTest.php in core/modules/ forum/ tests/ src/ Unit/ Breadcrumb/ ForumListingBreadcrumbBuilderTest.php 
1 string reference to 'ForumListingBreadcrumbBuilder'
- forum.services.yml in core/modules/ forum/ forum.services.yml 
- core/modules/forum/forum.services.yml
1 service uses ForumListingBreadcrumbBuilder
- forum.breadcrumb.listing in core/modules/ forum/ forum.services.yml 
- Drupal\forum\Breadcrumb\ForumListingBreadcrumbBuilder
File
- 
              core/modules/ forum/ src/ Breadcrumb/ ForumListingBreadcrumbBuilder.php, line 11 
Namespace
Drupal\forum\BreadcrumbView source
class ForumListingBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
  
  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return $route_match->getRouteName() == 'forum.page' && $route_match->getParameter('taxonomy_term');
  }
  
  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match) {
    $breadcrumb = parent::build($route_match);
    $breadcrumb->addCacheContexts([
      'route',
    ]);
    // Add all parent forums to breadcrumbs.
    /** @var \Drupal\taxonomy\TermInterface $term */
    $term = $route_match->getParameter('taxonomy_term');
    $term_id = $term->id();
    $breadcrumb->addCacheableDependency($term);
    $parents = $this->termStorage
      ->loadAllParents($term_id);
    if ($parents) {
      foreach (array_reverse($parents) as $parent) {
        if ($parent->id() != $term_id) {
          $breadcrumb->addCacheableDependency($parent);
          $breadcrumb->addLink(Link::createFromRoute($parent->label(), 'forum.page', [
            'taxonomy_term' => $parent->id(),
          ]));
        }
      }
    }
    return $breadcrumb;
  }
}Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides | 
|---|---|---|---|---|---|
| DeprecatedServicePropertyTrait::__get | public | function | Allows to access deprecated/removed properties. | ||
| ForumBreadcrumbBuilderBase::$config | protected | property | Configuration object for this builder. | ||
| ForumBreadcrumbBuilderBase::$deprecatedProperties | protected | property | |||
| ForumBreadcrumbBuilderBase::$entityTypeManager | protected | property | The entity type manager. | ||
| ForumBreadcrumbBuilderBase::$forumManager | protected | property | The forum manager service. | ||
| ForumBreadcrumbBuilderBase::$termStorage | protected | property | The taxonomy term storage. | ||
| ForumBreadcrumbBuilderBase::__construct | public | function | Constructs a forum breadcrumb builder object. | ||
| ForumListingBreadcrumbBuilder::applies | public | function | Whether this breadcrumb builder should be used to build the breadcrumb. | Overrides BreadcrumbBuilderInterface::applies | |
| ForumListingBreadcrumbBuilder::build | public | function | Builds the breadcrumb. | Overrides ForumBreadcrumbBuilderBase::build | |
| StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 1 | |
| 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. | 
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
