From 300ef9fc907c1f0c8be52cf741719d6c310f1944 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 22 Nov 2021 21:16:46 -0500 Subject: [PATCH] SearchKit - Cleanup hardcoded references to 'Contact' --- ext/search_kit/Civi/Search/Admin.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ext/search_kit/Civi/Search/Admin.php b/ext/search_kit/Civi/Search/Admin.php index 01de7d95ae..c1a8c39f75 100644 --- a/ext/search_kit/Civi/Search/Admin.php +++ b/ext/search_kit/Civi/Search/Admin.php @@ -180,21 +180,22 @@ class Admin { foreach ($allowedEntities as $entity) { // Multi-record custom field groups (to-date only the contact entity supports these) if (in_array('CustomValue', $entity['type'])) { + // TODO: Lookup target entity from custom group if someday other entities support multi-record custom data $targetEntity = $allowedEntities['Contact']; // Join from Custom group to Contact (n-1) - $alias = $entity['name'] . '_Contact_entity_id'; + $alias = "{$entity['name']}_{$targetEntity['name']}_entity_id"; $joins[$entity['name']][] = [ 'label' => $entity['title'] . ' ' . $targetEntity['title'], 'description' => '', - 'entity' => 'Contact', + 'entity' => $targetEntity['name'], 'conditions' => self::getJoinConditions('entity_id', $alias . '.id'), 'defaults' => self::getJoinDefaults($alias, $targetEntity), 'alias' => $alias, 'multi' => FALSE, ]; // Join from Contact to Custom group (n-n) - $alias = 'Contact_' . $entity['name'] . '_entity_id'; - $joins['Contact'][] = [ + $alias = "{$targetEntity['name']}_{$entity['name']}_entity_id"; + $joins[$targetEntity['name']][] = [ 'label' => $entity['title_plural'], 'description' => '', 'entity' => $entity['name'], -- 2.25.1