You are here

public function InvoiceBreadcrumbBuilder::build in Commerce Invoice 8.2

Builds the breadcrumb.

Parameters

\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.

Return value

\Drupal\Core\Breadcrumb\Breadcrumb A breadcrumb.

Overrides PathBasedBreadcrumbBuilder::build

File

src/InvoiceBreadcrumbBuilder.php, line 30

Class

InvoiceBreadcrumbBuilder
Defines the Commerce Invoice breadcrumb builder.

Namespace

Drupal\commerce_invoice

Code

public function build(RouteMatchInterface $route_match) {
  $current_path_info = $this->context
    ->getPathInfo();

  /** @var \Drupal\commerce_invoice\Entity\InvoiceInterface $invoice */
  $invoice = $route_match
    ->getParameter('commerce_invoice');
  $path = $invoice
    ->toUrl('collection')
    ->getInternalPath();
  $this->context
    ->setPathInfo('/' . trim($path, '/') . '/' . $invoice
    ->id());
  $breadcrumb = parent::build($route_match);

  // Restore the initial request path info.
  $this->context
    ->setPathInfo($current_path_info);
  return $breadcrumb;
}