abstract class ForumBreadcrumbBuilderBase in Zircon Profile 8
Same name and namespace in other branches
- 8.0 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 manager, and forum manager objects.
Hierarchy
- class \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of ForumBreadcrumbBuilderBase
File
- core/
modules/ forum/ src/ Breadcrumb/ ForumBreadcrumbBuilderBase.php, line 25 - Contains \Drupal\forum\Breadcrumb\ForumBreadcrumbBuilderBase.
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 manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The forum manager service.
*
* @var \Drupal\forum\ForumManagerInterface
*/
protected $forumManager;
/**
* Constructs a forum breadcrumb builder object.
*
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Drupal\forum\ForumManagerInterface $forum_manager
* The forum manager service.
*/
public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, ForumManagerInterface $forum_manager) {
$this->entityManager = $entity_manager;
$this->config = $config_factory
->get('forum.settings');
$this->forumManager = $forum_manager;
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$breadcrumb
->addCacheContexts([
'route',
]);
$links[] = Link::createFromRoute($this
->t('Home'), '<front>');
$vocabulary = $this->entityManager
->getStorage('taxonomy_vocabulary')
->load($this->config
->get('vocabulary'));
$breadcrumb
->addCacheableDependency($vocabulary);
$links[] = Link::createFromRoute($vocabulary
->label(), 'forum.index');
return $breadcrumb
->setLinks($links);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BreadcrumbBuilderInterface:: |
public | function | Whether this breadcrumb builder should be used to build the breadcrumb. | 7 |
ForumBreadcrumbBuilderBase:: |
protected | property | Configuration object for this builder. | |
ForumBreadcrumbBuilderBase:: |
protected | property | The entity manager. | |
ForumBreadcrumbBuilderBase:: |
protected | property | The forum manager service. | |
ForumBreadcrumbBuilderBase:: |
public | function |
Builds the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
2 |
ForumBreadcrumbBuilderBase:: |
public | function | Constructs a forum breadcrumb builder object. | |
StringTranslationTrait:: |
protected | property | The string translation service. | |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |