class HelpBreadcrumbBuilder

Same name in other branches
  1. 8.9.x core/modules/help_topics/src/HelpBreadcrumbBuilder.php \Drupal\help_topics\HelpBreadcrumbBuilder
  2. 10 core/modules/help_topics/src/HelpBreadcrumbBuilder.php \Drupal\help_topics\HelpBreadcrumbBuilder
  3. 10 core/modules/help/src/HelpBreadcrumbBuilder.php \Drupal\help\HelpBreadcrumbBuilder
  4. 11.x core/modules/help_topics/src/HelpBreadcrumbBuilder.php \Drupal\help_topics\HelpBreadcrumbBuilder
  5. 11.x core/modules/help/src/HelpBreadcrumbBuilder.php \Drupal\help\HelpBreadcrumbBuilder

Provides a breadcrumb builder for help topic pages.

@internal Help Topics is currently experimental and should only be leveraged by experimental modules and development releases of contributed modules. See https://www.drupal.org/core/experimental for more information.

Hierarchy

Expanded class hierarchy of HelpBreadcrumbBuilder

1 string reference to 'HelpBreadcrumbBuilder'
help_topics.services.yml in core/modules/help_topics/help_topics.services.yml
core/modules/help_topics/help_topics.services.yml
1 service uses HelpBreadcrumbBuilder
help.breadcrumb in core/modules/help_topics/help_topics.services.yml
Drupal\help_topics\HelpBreadcrumbBuilder

File

core/modules/help_topics/src/HelpBreadcrumbBuilder.php, line 20

Namespace

Drupal\help_topics
View source
class HelpBreadcrumbBuilder implements BreadcrumbBuilderInterface {
    use StringTranslationTrait;
    
    /**
     * Constructs the HelpBreadcrumbBuilder.
     *
     * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
     *   The translation service.
     */
    public function __construct(TranslationInterface $string_translation) {
        $this->stringTranslation = $string_translation;
    }
    
    /**
     * {@inheritdoc}
     */
    public function applies(RouteMatchInterface $route_match) {
        return $route_match->getRouteName() == 'help.help_topic';
    }
    
    /**
     * {@inheritdoc}
     */
    public function build(RouteMatchInterface $route_match) {
        $breadcrumb = new Breadcrumb();
        $breadcrumb->addCacheContexts([
            'url.path.parent',
        ]);
        $breadcrumb->addLink(Link::createFromRoute($this->t('Home'), '<front>'));
        $breadcrumb->addLink(Link::createFromRoute($this->t('Administration'), 'system.admin'));
        $breadcrumb->addLink(Link::createFromRoute($this->t('Help'), 'help.main'));
        return $breadcrumb;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
HelpBreadcrumbBuilder::applies public function Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface::applies
HelpBreadcrumbBuilder::build public function Builds the breadcrumb. Overrides BreadcrumbBuilderInterface::build
HelpBreadcrumbBuilder::__construct public function Constructs the HelpBreadcrumbBuilder.
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.