public function CampaignMonitorManager::getCustomFields in Campaign Monitor 8.2
Fetch custom fields for a given list.
Store this information locally in the list cache. The information is stored as a keyed array on the list array under the "CustomFields" key.
Parameters
string $listId: The Campaign Monitor list ID.
Return value
mixed|array|false An array with the information or FALSE on failure.
1 call to CampaignMonitorManager::getCustomFields()
- CampaignMonitorManager::getExtendedList in src/
CampaignMonitorManager.php - Get all information available about a given list.
File
- src/
CampaignMonitorManager.php, line 493
Class
- CampaignMonitorManager
- Manager for Campaignmonitor.
Namespace
Drupal\campaignmonitorCode
public function getCustomFields($listId) {
// If the lists have not been loaded yet, get them as they build the basic
// cache.
if (empty($this->lists)) {
$this
->getLists();
}
// Test that the listId is valid.
if (!isset($this->lists[$listId])) {
$this
->addError($this
->t('Unknown list id @listID.', [
'@listID' => $listId,
]));
return FALSE;
}
// If custom fields are not set on the list, then create the list object and
// fetch custom fields into a keyed array.
if (!isset($this->lists[$listId]['CustomFields'])) {
if ($obj = $this
->createListObj($listId)) {
$result = $obj
->get_custom_fields();
if ($result
->was_successful()) {
$this->lists[$listId]['CustomFields'] = [];
foreach ($result->response as $field) {
foreach ($field as $name => $details) {
$this->lists[$listId]['CustomFields'][$field->Key][$name] = $details;
}
}
// Update cache with list details.
$this->cacheBackend
->set('campaignmonitor_lists', $this->lists);
}
else {
$this
->addError($result->response->Message, $result->http_status_code);
}
}
else {
return FALSE;
}
}
return $this->lists[$listId]['CustomFields'];
}