fix bug: undefined indexes

This commit is contained in:
Marc Michalsky forumZFD 2021-02-08 17:32:56 +01:00
parent b1f0ddc5dc
commit a79e534099
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
2 changed files with 42 additions and 23 deletions

View file

@ -72,11 +72,15 @@ class CRM_TwingleCampaign_Utils_ExtensionCache {
// Get ids for Twingle related campaign types
foreach ($this->campaigns['campaign_types'] as $campaign_type) {
$this->campaigns['campaign_types'][$campaign_type['name']]['id'] = civicrm_api3(
$campaign_type_id = civicrm_api3(
'OptionValue',
'get',
['sequential' => 1, 'name' => $campaign_type['name']]
)['values'][0]['value'];
)['values'];
if ($campaign_type_id) {
$this->campaigns['campaign_types'][$campaign_type['name']]['id'] =
$campaign_type_id[0]['value'];
}
}
}
@ -84,8 +88,10 @@ class CRM_TwingleCampaign_Utils_ExtensionCache {
/**
* ## Get custom field mapping
* Returns a mapping custom fields of the TwingleCampaign extension.
* * If a **$fieldName** is provided, this method returns its custom field name
* * If a **$fieldName** is provided, this method returns its custom field
* name
* * Without parameter, the method returns the whole mapping
*
* @param string|null $fieldName
*
* @return array|string