' . t('About') . ''; $output .= '

' . t('Enable EITHER this OR "OpenCase Cases". This one links activities directly to people, which is simpler and therefore what some orgs prefer.') . '

'; return $output; default: } } function opencase_no_cases_entity_base_field_info($entity_type) { if ($entity_type->id() === 'oc_activity') { $fields = array(); $fields['actors_involved'] = BaseFieldDefinition::create('entity_reference') ->setLabel(t('Participants')) ->setDescription(t('People involved in this activity. To add one, start typing their name.')) ->setSetting('target_type', 'oc_actor') ->setSetting('handler', 'default') ->setTranslatable(TRUE) ->setCardinality(-1) ->setDisplayOptions('form', [ 'label' => 'above', 'type' => 'entity_reference_autocomplete', 'weight' => -2, 'settings' => [ 'match_operator' => 'CONTAINS', 'size' => '60', 'autocomplete_type' => 'tags', 'placeholder' => '', ], ]) ->setDisplayOptions('view', [ 'label' => 'above', ]) ->setDefaultValueCallback('opencase_no_cases_actors_involved_callback') ->setRequired(TRUE); } return $fields; } /** * When creating an activity, it sets the first involved party to the actor * id from the URL, and the second to the author's linked actor * (if it exists and is different) */ function opencase_no_cases_actors_involved_callback() { $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]); }