class RegistrantBreadcrumbBuilder in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Breadcrumb/RegistrantBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\RegistrantBreadcrumbBuilder
- 3.x src/Breadcrumb/RegistrantBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\RegistrantBreadcrumbBuilder
Provides a breadcrumb builder for registrants.
Hierarchy
- class \Drupal\rng\Breadcrumb\RegistrantBreadcrumbBuilder implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of RegistrantBreadcrumbBuilder
1 string reference to 'RegistrantBreadcrumbBuilder'
1 service uses RegistrantBreadcrumbBuilder
File
- src/
Breadcrumb/ RegistrantBreadcrumbBuilder.php, line 15
Namespace
Drupal\rng\BreadcrumbView source
class RegistrantBreadcrumbBuilder implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
$registrant = $route_match
->getParameter('registrant');
return $registrant instanceof RegistrantInterface;
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$links[] = Link::createFromRoute($this
->t('Home'), '<front>');
/** @var \Drupal\rng\RegistrantInterface $registrant */
$registrant = $route_match
->getParameter('registrant');
if ($registration = $registrant
->getRegistration()) {
if ($event = $registration
->getEvent()) {
$links[] = new Link($event
->label(), $event
->toUrl());
}
$links[] = new Link($registration
->label(), $registration
->toUrl());
}
// Add registrant to the breadcrumb if the current route is not canonical.
if ('entity.registrant.canonical' != $route_match
->getRouteName()) {
$links[] = new Link($registrant
->label(), $registrant
->toUrl());
}
$breadcrumb = new Breadcrumb();
return $breadcrumb
->setLinks($links)
->addCacheContexts([
'route.name',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RegistrantBreadcrumbBuilder:: |
public | function |
Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
RegistrantBreadcrumbBuilder:: |
public | function |
Builds the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |