You are here

class ThunderNodeEditBreadcrumbBuilder in Thunder 6.1.x

Same name and namespace in other branches
  1. 6.2.x src/Breadcrumb/ThunderNodeEditBreadcrumbBuilder.php \Drupal\thunder\Breadcrumb\ThunderNodeEditBreadcrumbBuilder

Class to define the breadcrumb builder.

Hierarchy

Expanded class hierarchy of ThunderNodeEditBreadcrumbBuilder

1 string reference to 'ThunderNodeEditBreadcrumbBuilder'
thunder.services.yml in ./thunder.services.yml
thunder.services.yml
1 service uses ThunderNodeEditBreadcrumbBuilder
thunder.breadcrumb.default in ./thunder.services.yml
Drupal\thunder\Breadcrumb\ThunderNodeEditBreadcrumbBuilder

File

src/Breadcrumb/ThunderNodeEditBreadcrumbBuilder.php, line 14

Namespace

Drupal\thunder\Breadcrumb
View source
class ThunderNodeEditBreadcrumbBuilder implements BreadcrumbBuilderInterface {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    return in_array($route_match
      ->getRouteName(), [
      'entity.node.edit_form',
      'node.add',
      'node.add_page',
    ]);
  }

  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match) {
    $breadcrumb = new Breadcrumb();
    $breadcrumb
      ->addCacheContexts([
      'route',
    ]);
    $links[] = Link::createFromRoute($this
      ->t('Home'), '<front>');
    $links[] = Link::createFromRoute($this
      ->t('Overview'), 'system.admin_content');
    if ($route_match
      ->getRouteName() == 'node.add') {
      $links[] = Link::createFromRoute($this
        ->t('Add content'), 'node.add_page');
    }
    return $breadcrumb
      ->setLinks($links);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
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.
ThunderNodeEditBreadcrumbBuilder::applies public function Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface::applies
ThunderNodeEditBreadcrumbBuilder::build public function Builds the breadcrumb. Overrides BreadcrumbBuilderInterface::build