From f0601ad64206879bd05ba3cead910f8435186b70 Mon Sep 17 00:00:00 2001 From: Jens Schuppe Date: Thu, 14 Nov 2024 13:24:46 +0100 Subject: [PATCH] Don't expose ECK entities without subtypes to afform --- Civi/Eck/API/Entity.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Civi/Eck/API/Entity.php b/Civi/Eck/API/Entity.php index 29a977e..809771a 100644 --- a/Civi/Eck/API/Entity.php +++ b/Civi/Eck/API/Entity.php @@ -90,13 +90,15 @@ public function onApi4EntityTypes(GenericHookEvent $event): void { */ public static function afformEntityTypes(GenericHookEvent $e): void { foreach (\CRM_Eck_BAO_EckEntityType::getEntityTypes() as $entityType) { - $e->entities[$entityType['entity_name']] = [ - 'entity' => $entityType['entity_name'], - 'label' => $entityType['label'], - 'icon' => $entityType['icon'], - 'type' => 'primary', - 'defaults' => '{}', - ]; + if ([] !== \CRM_Eck_BAO_EckEntityType::getSubTypes($entityType['name'])) { + $e->entities[$entityType['entity_name']] = [ + 'entity' => $entityType['entity_name'], + 'label' => $entityType['label'], + 'icon' => $entityType['icon'], + 'type' => 'primary', + 'defaults' => '{}', + ]; + } } }