public function CampaignMonitorManager::getListStats in Campaign Monitor 8.2
Fetch stats about a given list including subscribers and unsubscribers.
This information is temporarily stored in the local cache. The default timeout is 360 seconds.
Parameters
string $listId: The Campaign Monitor list ID.
Return value
mixed|array|false An array containing the stats or FALSE on failure.
File
- src/
CampaignMonitorManager.php, line 626
Class
- CampaignMonitorManager
- Manager for Campaignmonitor.
Namespace
Drupal\campaignmonitorCode
public function getListStats($listId) {
$fetch = FALSE;
if (!isset($this->listStats[$listId])) {
// Not found inside object, try the cache.
if (($cache = $this->cacheBackend
->get('campaignmonitor_list_stats')) && !empty($cache->data)) {
// Cache information found.
$this->listStats = $cache->data;
if (!isset($this->listStats[$listId])) {
// Not found inside cache either.
$fetch = TRUE;
}
}
else {
// No cache found or expired.
$fetch = TRUE;
}
}
if ($fetch) {
if ($obj = $this
->createListObj($listId)) {
// Get stats from Campaign Monitor.
$result = $obj
->get_stats();
if ($result
->was_successful()) {
$this->listStats[$listId] = (array) $result->response;
// Update the cache.
$this->cacheBackend
->set('campaignmonitor_list_stats', $this->listStats, $this
->getCacheTimeout());
}
else {
$this
->addError($result->response->Message, $result->http_status_code);
return FALSE;
}
}
else {
return FALSE;
}
}
return $this->listStats[$listId];
}