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