fixed breadcrumbs so they work for ciac
This commit is contained in:
parent
2f07a2b9aa
commit
ffb56ab09f
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Drupal\opencase_cases\Entity;
|
namespace Drupal\opencase_cases\Entity;
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\ContentEntityBase;
|
||||||
use Drupal\Core\Entity\EntityStorageInterface;
|
use Drupal\Core\Entity\EntityStorageInterface;
|
||||||
use Drupal\Core\Field\BaseFieldDefinition;
|
use Drupal\Core\Field\BaseFieldDefinition;
|
||||||
use Drupal\Core\Entity\RevisionableContentEntityBase;
|
use Drupal\Core\Entity\RevisionableContentEntityBase;
|
||||||
@ -116,6 +117,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
|
|||||||
else return [];
|
else return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTargetEntity(): ContentEntityBase {
|
||||||
|
if (!$this->oc_target->isEmpty()) {
|
||||||
|
return $this->oc_target->entity;
|
||||||
|
} elseif ($this->hasField('client') && !$this->client->isEmpty()) {
|
||||||
|
return $this->client->entity;
|
||||||
|
} else {
|
||||||
|
throw new \Exception('No target found on case');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@ use Drupal\Core\Breadcrumb\Breadcrumb;
|
|||||||
use Drupal\opencase_cases\Entity\OCCase;
|
use Drupal\opencase_cases\Entity\OCCase;
|
||||||
use Drupal\Core\Entity\ContentEntityBase;
|
use Drupal\Core\Entity\ContentEntityBase;
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
use Drupal\Core\Routing\RouteMatchInterface;
|
||||||
|
use Drupal\opencase_entities\Entity\OCOrganisation;
|
||||||
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
use Drupal\Core\Breadcrumb\BreadcrumbBuilderInterface;
|
||||||
|
|
||||||
class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
||||||
@ -29,13 +30,20 @@ class BreadcrumbBuilder implements BreadcrumbBuilderInterface {
|
|||||||
return \Drupal::service('title_resolver')->getTitle($request, $route_match->getRouteObject());
|
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) {
|
private function addLinksForOrganisation(ContentEntityBase $entity) {
|
||||||
$fields = ['field_umbrella_client'];
|
$fields = ['field_umbrella_client'];
|
||||||
$this->addLinks($entity, $fields);
|
$this->addLinks($entity, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addLinksForCase(OCCase $case) {
|
private function addLinksForCase(OCCase $case) {
|
||||||
$fields = ['client', 'field_project'];
|
$fields = ['client', 'field_project'];
|
||||||
$this->addLinksForOrganisation($case->get('client')->entity);
|
$this->addLinksForCaseTarget($case->getTargetEntity());
|
||||||
$this->addLinks($case, $fields);
|
$this->addLinks($case, $fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user