Skip to content
Snippets Groups Projects

Issue #3198500: Allow fallback on lower priority breadcrumb builders

Merged Robin De Herdt requested to merge issue/custom_breadcrumbs-3198500:1.x into 1.x
1 file
+ 35
0
Compare changes
  • Side-by-side
  • Inline
+ 35
0
@@ -156,6 +156,10 @@ class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
return FALSE;
}
if (!$this->matchPaths($route_match) && !$this->matchEntity($route_match)) {
return FALSE;
}
return TRUE;
}
@@ -454,6 +458,37 @@ class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
return FALSE;
}
/**
* Check breadcrumbs by entity.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* Route match.
*
* @return bool
* True if a match was found, false otherwise.
*
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
protected function matchEntity(RouteMatchInterface $route_match) {
$params = $route_match->getParameters()->all();
$entityTypeIds = array_keys($params);
$entityTypeId = reset($entityTypeIds);
$breadcrumbSettings = $this->entityTypeManager->getStorage('custom_breadcrumbs')
->loadByProperties([
'entityType' => $entityTypeId,
'status' => TRUE,
'type' => 1,
]);
$this->filterPerBundle($breadcrumbSettings, $route_match);
$this->filterPerLanguage($breadcrumbSettings);
return !empty($breadcrumbSettings);
}
/**
* Helper method to trim title.
*
Loading