class ForumBreadcrumbBuilderBase
Same name in other branches
- 9 core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase
- 8.9.x core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase
- 11.x core/modules/forum/src/Breadcrumb/ForumBreadcrumbBuilderBase.php \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase
Provides a forum breadcrumb base class.
This just holds the dependency-injected config, entity type manager, and forum manager objects.
Hierarchy
- class \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase implements \Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of ForumBreadcrumbBuilderBase
File
-
core/
modules/ forum/ src/ Breadcrumb/ ForumBreadcrumbBuilderBase.php, line 21
Namespace
Drupal\forum\BreadcrumbView source
abstract class ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* Configuration object for this builder.
*
* @var \Drupal\Core\Config\Config
*/
protected $config;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The forum manager service.
*
* @var \Drupal\forum\ForumManagerInterface
*/
protected $forumManager;
/**
* The taxonomy term storage.
*
* @var \Drupal\taxonomy\TermStorageInterface
*/
protected $termStorage;
/**
* Constructs a forum breadcrumb builder object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Drupal\forum\ForumManagerInterface $forum_manager
* The forum manager service.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, ConfigFactoryInterface $config_factory, ForumManagerInterface $forum_manager, TranslationInterface $string_translation) {
$this->entityTypeManager = $entity_type_manager;
$this->config = $config_factory->get('forum.settings');
$this->forumManager = $forum_manager;
$this->setStringTranslation($string_translation);
$this->termStorage = $entity_type_manager->getStorage('taxonomy_term');
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$breadcrumb->addCacheContexts([
'route',
]);
$links[] = Link::createFromRoute($this->t('Home'), '<front>');
$vocabulary = $this->entityTypeManager
->getStorage('taxonomy_vocabulary')
->load($this->config
->get('vocabulary'));
$breadcrumb->addCacheableDependency($vocabulary);
$links[] = Link::createFromRoute($vocabulary->label(), 'forum.index');
return $breadcrumb->setLinks($links);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
BreadcrumbBuilderInterface::applies | public | function | Whether this breadcrumb builder should be used to build the breadcrumb. | 7 | |
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::build | public | function | Builds the breadcrumb. | Overrides BreadcrumbBuilderInterface::build | 2 |
ForumBreadcrumbBuilderBase::__construct | public | function | Constructs a forum breadcrumb builder object. | ||
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.