class RuleComponentBreadcrumbBuilder in RNG - Events and Registrations 8
Same name and namespace in other branches
- 8.2 src/Breadcrumb/RuleComponentBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\RuleComponentBreadcrumbBuilder
- 3.x src/Breadcrumb/RuleComponentBreadcrumbBuilder.php \Drupal\rng\Breadcrumb\RuleComponentBreadcrumbBuilder
Provides a breadcrumb builder for RNG rule components.
Hierarchy
- class \Drupal\rng\Breadcrumb\RuleComponentBreadcrumbBuilder implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of RuleComponentBreadcrumbBuilder
1 string reference to 'RuleComponentBreadcrumbBuilder'
1 service uses RuleComponentBreadcrumbBuilder
File
- src/
Breadcrumb/ RuleComponentBreadcrumbBuilder.php, line 15
Namespace
Drupal\rng\BreadcrumbView source
class RuleComponentBreadcrumbBuilder implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
$component = $route_match
->getParameter('rng_rule_component');
return $component instanceof RuleComponentInterface;
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$links = array(
Link::createFromRoute($this
->t('Home'), '<front>'),
);
/** @var \Drupal\rng\RuleComponentInterface $component */
$component = $route_match
->getParameter('rng_rule_component');
if ($rule = $component
->getRule()) {
if ($event = $rule
->getEvent()) {
$links[] = new Link($event
->label(), $event
->urlInfo());
}
}
$breadcrumb = new Breadcrumb();
return $breadcrumb
->setLinks($links)
->addCacheContexts([
'route.name',
]);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RuleComponentBreadcrumbBuilder:: |
public | function |
Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
RuleComponentBreadcrumbBuilder:: |
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. |