You are here

class GroupBreadcrumbBuilder in RNG - Events and Registrations 8

Same name and namespace in other branches
  1. 8.2 src/Breadcrumb/GroupBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\GroupBreadcrumbBuilder
  2. 3.x src/Breadcrumb/GroupBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\GroupBreadcrumbBuilder

Provides a breadcrumb builder for groups.

Hierarchy

Expanded class hierarchy of GroupBreadcrumbBuilder

1 string reference to 'GroupBreadcrumbBuilder'
rng.services.yml in ./rng.services.yml
rng.services.yml
1 service uses GroupBreadcrumbBuilder
rng.breadcrumb.registration_group in ./rng.services.yml
Drupal\rng\Breadcrumb\GroupBreadcrumbBuilder

File

src/Breadcrumb/GroupBreadcrumbBuilder.php, line 15

Namespace

Drupal\rng\Breadcrumb
View source
class GroupBreadcrumbBuilder implements BreadcrumbBuilderInterface {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    $group = $route_match
      ->getParameter('registration_group');
    return $group instanceof GroupInterface;
  }

  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match) {
    $links = array(
      Link::createFromRoute($this
        ->t('Home'), '<front>'),
    );

    /** @var \Drupal\rng\GroupInterface $group */
    $group = $route_match
      ->getParameter('registration_group');
    if ($event = $group
      ->getEvent()) {
      $links[] = new Link($event
        ->label(), $event
        ->urlInfo());
    }
    $breadcrumb = new Breadcrumb();
    return $breadcrumb
      ->setLinks($links)
      ->addCacheContexts([
      'route.name',
    ]);
  }

}

Members

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