public function ProductBreadcrumbBuilder::applies in Commerce Demo 8
Whether this breadcrumb builder should be used to build the breadcrumb.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
Return value
bool TRUE if this builder should be used or FALSE to let other builders decide.
Overrides BreadcrumbBuilderInterface::applies
File
- src/
ProductBreadcrumbBuilder.php, line 69
Class
- ProductBreadcrumbBuilder
- Builds a product breadcrumb based on the "field_product_categories" field.
Namespace
Drupal\commerce_demoCode
public function applies(RouteMatchInterface $route_match) {
if ($route_match
->getRouteName() !== 'entity.commerce_product.canonical') {
return FALSE;
}
try {
$this->routeProvider
->getRouteByName('view.product_catalog.page_1');
} catch (RouteNotFoundException $e) {
// The catalog View may have been disabled or deleted.
return FALSE;
}
$product = $route_match
->getParameter('commerce_product');
return $product && $product
->hasField('field_product_categories');
}