throw error if no default project is found

This commit is contained in:
Marc Michalsky 2023-09-06 16:45:13 +02:00
parent fd99f3b24f
commit 89df7482a6
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9

View file

@ -350,6 +350,8 @@ class CRM_Twingle_Profile {
* @param $project_id * @param $project_id
* *
* @return CRM_Twingle_Profile * @return CRM_Twingle_Profile
* @throws \CRM\Twingle\Exceptions\ProfileException
* @throws \Civi\Core\Exception\DBQueryException
*/ */
public static function getProfileForProject($project_id) { public static function getProfileForProject($project_id) {
$profiles = self::getProfiles(); $profiles = self::getProfiles();
@ -361,7 +363,16 @@ class CRM_Twingle_Profile {
} }
// If none matches, use the default 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
);
}
} }
/** /**