Loading src/BreadcrumbBuilder.php +35 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,10 @@ class BreadcrumbBuilder implements BreadcrumbBuilderInterface { return FALSE; } if (!$this->matchPaths($route_match) && !$this->matchEntity($route_match)) { return FALSE; } return TRUE; } Loading Loading @@ -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 Loading
src/BreadcrumbBuilder.php +35 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,10 @@ class BreadcrumbBuilder implements BreadcrumbBuilderInterface { return FALSE; } if (!$this->matchPaths($route_match) && !$this->matchEntity($route_match)) { return FALSE; } return TRUE; } Loading Loading @@ -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