added another null check to contextual menu

This commit is contained in:
naomi 2018-07-19 14:23:44 +02:00
parent b5f567f872
commit d2bd27c960
1 changed files with 6 additions and 3 deletions

View File

@ -101,13 +101,16 @@ class ContextualMenu extends BlockBase {
private function casePage() {
$case = \Drupal::routeMatch()->getParameter('oc_case');
$actor_id = \Drupal::service('user.private_tempstore')->get('opencase')->get('actor_id');
if ($actor_id) { // there is not always one stored.
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
if ($actor) {
$actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id);
if ($actor) { // actor may have been deleted.
$caseListLink = $this->getCaseListLink($actor);
} else {
$caseListLink = $this->getCaseListLinkAll();
}
} else {
$caseListLink = $this->getCaseListLinkAll();
}
$links = [$caseListLink, $this->getActivityListLink($case)];
return $this->asNavLinks($links);
}