From 2a31b1c8ce2b5419b6f38989871f3adf81ae3ea5 Mon Sep 17 00:00:00 2001 From: naomi Date: Mon, 9 Jul 2018 12:11:07 +0200 Subject: [PATCH] added linked actor of logged in user to new case --- modules/opencase_entities/src/Entity/OCCase.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/opencase_entities/src/Entity/OCCase.php b/modules/opencase_entities/src/Entity/OCCase.php index 9cbedf6..3ce95a2 100644 --- a/modules/opencase_entities/src/Entity/OCCase.php +++ b/modules/opencase_entities/src/Entity/OCCase.php @@ -76,10 +76,13 @@ class OCCase extends RevisionableContentEntityBase implements OCCaseInterface { /** * When creating a case, it sets the first involved party to the actor - * id from the URL. + * id from the URL, and the second to the author's linked actor + * (if it exists and is different) */ public static function defaultVal() { - return array(\Drupal::request()->query->get('actor_id')); + $author_linked_actor_id = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id())->get('field_linked_opencase_actor')->target_id; + $currently_viewed_actor_id = \Drupal::request()->query->get('actor_id'); + return array_unique([$currently_viewed_actor_id, $author_linked_actor_id]); } /**