class ForumNodeBreadcrumbBuilder
Same name in other branches
- 8.9.x core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder
- 10 core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder
- 11.x core/modules/forum/src/Breadcrumb/ForumNodeBreadcrumbBuilder.php \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder
Breadcrumb builder for forum nodes.
Hierarchy
- class \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase implements \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder extends \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase
Expanded class hierarchy of ForumNodeBreadcrumbBuilder
1 file declares its use of ForumNodeBreadcrumbBuilder
- ForumNodeBreadcrumbBuilderTest.php in core/
modules/ forum/ tests/ src/ Unit/ Breadcrumb/ ForumNodeBreadcrumbBuilderTest.php
1 string reference to 'ForumNodeBreadcrumbBuilder'
- forum.services.yml in core/
modules/ forum/ forum.services.yml - core/modules/forum/forum.services.yml
1 service uses ForumNodeBreadcrumbBuilder
- forum.breadcrumb.node in core/
modules/ forum/ forum.services.yml - Drupal\forum\Breadcrumb\ForumNodeBreadcrumbBuilder
File
-
core/
modules/ forum/ src/ Breadcrumb/ ForumNodeBreadcrumbBuilder.php, line 11
Namespace
Drupal\forum\BreadcrumbView source
class ForumNodeBreadcrumbBuilder extends ForumBreadcrumbBuilderBase {
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return $route_match->getRouteName() == 'entity.node.canonical' && $route_match->getParameter('node') && $this->forumManager
->checkNodeType($route_match->getParameter('node'));
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = parent::build($route_match);
$breadcrumb->addCacheContexts([
'route',
]);
$parents = $this->termStorage
->loadAllParents($route_match->getParameter('node')->forum_tid);
if ($parents) {
$parents = array_reverse($parents);
foreach ($parents as $parent) {
$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 |
---|---|---|---|---|---|
ForumBreadcrumbBuilderBase::$config | protected | property | Configuration object for this builder. | ||
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. | ||
ForumNodeBreadcrumbBuilder::applies | public | function | Whether this breadcrumb builder should be used to build the breadcrumb. | Overrides BreadcrumbBuilderInterface::applies | |
ForumNodeBreadcrumbBuilder::build | public | function | Builds the breadcrumb. | Overrides ForumBreadcrumbBuilderBase::build | |
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
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.