class CartBreadcrumbBuilder in Ubercart 8.4
Provides a custom breadcrumb builder for the cart page.
Hierarchy
- class \Drupal\uc_cart\CartBreadcrumbBuilder implements BreadcrumbBuilderInterface uses StringTranslationTrait
Expanded class hierarchy of CartBreadcrumbBuilder
1 string reference to 'CartBreadcrumbBuilder'
- uc_cart.services.yml in uc_cart/
uc_cart.services.yml - uc_cart/uc_cart.services.yml
1 service uses CartBreadcrumbBuilder
File
- uc_cart/
src/ CartBreadcrumbBuilder.php, line 15
Namespace
Drupal\uc_cartView source
class CartBreadcrumbBuilder implements BreadcrumbBuilderInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function applies(RouteMatchInterface $route_match) {
return $route_match
->getRouteName() == 'uc_cart.cart' && \Drupal::config('uc_cart.settings')
->get('breadcrumb_text');
}
/**
* {@inheritdoc}
*/
public function build(RouteMatchInterface $route_match) {
$config = \Drupal::config('uc_cart.settings');
$text = $config
->get('breadcrumb_text');
$links[] = Link::createFromRoute($this
->t('Home'), '<front>');
$links[] = Link::fromTextAndUrl($text, Url::fromUri('internal:/' . $config
->get('breadcrumb_url'), [
'absolute' => TRUE,
]));
$breadcrumb = new Breadcrumb();
$breadcrumb
->setLinks($links);
return $breadcrumb;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CartBreadcrumbBuilder:: |
public | function |
Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface:: |
|
CartBreadcrumbBuilder:: |
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. |