From 89df7482a6be72bfbd0ead47ad3367cf9098c416 Mon Sep 17 00:00:00 2001 From: Marc Michalsky Date: Wed, 6 Sep 2023 16:45:13 +0200 Subject: [PATCH] throw error if no default project is found --- CRM/Twingle/Profile.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CRM/Twingle/Profile.php b/CRM/Twingle/Profile.php index 0f9115e..80238be 100644 --- a/CRM/Twingle/Profile.php +++ b/CRM/Twingle/Profile.php @@ -350,6 +350,8 @@ class CRM_Twingle_Profile { * @param $project_id * * @return CRM_Twingle_Profile + * @throws \CRM\Twingle\Exceptions\ProfileException + * @throws \Civi\Core\Exception\DBQueryException */ public static function getProfileForProject($project_id) { $profiles = self::getProfiles(); @@ -361,7 +363,16 @@ class CRM_Twingle_Profile { } // If none matches, use the default profile. - return $profiles['default']; + $default_profile = $profiles['default']; + if (!empty($default_profile)) { + return $default_profile; + } + else { + throw new ProfileException( + 'Could not find default profile', + ProfileException::ERROR_CODE_DEFAULT_PROFILE_NOT_FOUND + ); + } } /**