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

@ -2,6 +2,7 @@
namespace Drupal\opencase_cases\Entity;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\RevisionableContentEntityBase;
@ -116,6 +117,16 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface
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}
*/