You are here

class RegistrationBreadcrumbBuilder in RNG - Events and Registrations 8.2

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

Provides a breadcrumb builder for registrations.

Hierarchy

Expanded class hierarchy of RegistrationBreadcrumbBuilder

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

File

src/Breadcrumb/RegistrationBreadcrumbBuilder.php, line 15

Namespace

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

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

  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match) {
    $links = [
      Link::createFromRoute($this
        ->t('Home'), '<front>'),
    ];
    $registration = $route_match
      ->getParameter('registration');
    if ($event = $registration
      ->getEvent()) {
      $links[] = new Link($event
        ->label(), $event
        ->urlInfo());
    }
    if ('entity.registration.canonical' != $route_match
      ->getRouteName()) {
      $links[] = new Link($registration
        ->label(), $registration
        ->urlInfo());
    }
    $breadcrumb = new Breadcrumb();
    return $breadcrumb
      ->setLinks($links)
      ->addCacheContexts([
      'route.name',
    ]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RegistrationBreadcrumbBuilder::applies public function Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface::applies
RegistrationBreadcrumbBuilder::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.