You are here

class CartBreadcrumbBuilder in Ubercart 8.4

Provides a custom breadcrumb builder for the cart page.

Hierarchy

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
uc_cart.breadcrumb in uc_cart/uc_cart.services.yml
Drupal\uc_cart\CartBreadcrumbBuilder

File

uc_cart/src/CartBreadcrumbBuilder.php, line 15

Namespace

Drupal\uc_cart
View 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

Namesort descending Modifiers Type Description Overrides
CartBreadcrumbBuilder::applies public function Whether this breadcrumb builder should be used to build the breadcrumb. Overrides BreadcrumbBuilderInterface::applies
CartBreadcrumbBuilder::build public function Builds the breadcrumb. Overrides BreadcrumbBuilderInterface::build
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.