HelpBreadcrumbBuilder.php

Same filename in this branch
  1. 10 core/modules/help_topics/src/HelpBreadcrumbBuilder.php
Same filename in other branches
  1. 9 core/modules/help_topics/src/HelpBreadcrumbBuilder.php
  2. 8.9.x core/modules/help_topics/src/HelpBreadcrumbBuilder.php
  3. 11.x core/modules/help_topics/src/HelpBreadcrumbBuilder.php
  4. 11.x core/modules/help/src/HelpBreadcrumbBuilder.php

Namespace

Drupal\help

File

core/modules/help/src/HelpBreadcrumbBuilder.php

View source
<?php

namespace Drupal\help;

use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
use Drupal\Core\Link;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Provides a breadcrumb builder for help topic pages.
 *
 * @internal
 *   Tagged services are internal.
 */
class HelpBreadcrumbBuilder implements BreadcrumbBuilderInterface {
    
    /**
     * {@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(new TranslatableMarkup('Home'), '<front>'));
        $breadcrumb->addLink(Link::createFromRoute(new TranslatableMarkup('Administration'), 'system.admin'));
        $breadcrumb->addLink(Link::createFromRoute(new TranslatableMarkup('Help'), 'help.main'));
        return $breadcrumb;
    }

}

Classes

Title Deprecated Summary
HelpBreadcrumbBuilder Provides a breadcrumb builder for help topic pages.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.