fixed breadcrumbs so they work for ciac

This commit is contained in:
2022-06-07 13:07:18 +01:00
parent 2f07a2b9aa
commit ffb56ab09f
2 changed files with 20 additions and 1 deletions

View File

@ -7,6 +7,7 @@ use Drupal\Core\Breadcrumb\Breadcrumb;
use Drupal\opencase_cases\Entity\OCCase;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\opencase_entities\Entity\OCOrganisation;
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
@ -29,13 +30,20 @@ class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
return \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
}
private function addLinksForCaseTarget(ContentEntityBase $entity) {
if ($entity instanceof OCOrganisation) {
$this->addLinksForOrganisation($entity);
}
}
private function addLinksForOrganisation(ContentEntityBase $entity) {
$fields = ['field_umbrella_client'];
$this->addLinks($entity, $fields);
}
private function addLinksForCase(OCCase $case) {
$fields = ['client', 'field_project'];
$this->addLinksForOrganisation($case->get('client')->entity);
$this->addLinksForCaseTarget($case->getTargetEntity());
$this->addLinks($case, $fields);
}