class RecipeBreadcrumbBuilder in Recipe 8.2
Builds breadcrumbs for Recipe nodes.
Hierarchy
- class \Drupal\recipe\RecipeBreadcrumbBuilder implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of RecipeBreadcrumbBuilder
1 string reference to 'RecipeBreadcrumbBuilder'
1 service uses RecipeBreadcrumbBuilder
File
- src/
RecipeBreadcrumbBuilder.php, line 15
Namespace
Drupal\recipeView source
class RecipeBreadcrumbBuilder implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
$node = $route_match
->getParameter('node');
$match = $node instanceof NodeInterface && $node
->getType() == 'recipe';
return $match;
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$links[] = Link::createFromRoute($this
->t('Home'), '<front>');
$links[] = Link::createFromRoute($this
->t('Recipes'), 'recipe.landing_page');
$breadcrumb
->setLinks($links);
$breadcrumb
->addCacheContexts([
'route',
]);
return $breadcrumb;
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RecipeBreadcrumbBuilder:: |
public | function |
Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
RecipeBreadcrumbBuilder:: |
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. |