public function MandrillReportsService::getSenders in Mandrill 8
Gets sender data formatted for reports.
Return value
array
File
- modules/
mandrill_reports/ src/ MandrillReportsService.php, line 100 - Contains \Drupal\mandrill_reports\MandrillReportsService.
Class
- MandrillReportsService
- Mandrill Reports service.
Namespace
Drupal\mandrill_reportsCode
public function getSenders() {
$cache = \Drupal::cache('mandrill');
$cached_senders = $cache
->get('senders');
if (!empty($cached_senders)) {
return $cached_senders->data;
}
$data = array();
$senders = $this->mandrill_api
->getSenders();
foreach ($senders as $sender) {
try {
$data[$sender['address']] = $this->mandrill_api
->getSender($sender['address']);
$data[$sender['address']]['time_series'] = $this->mandrill_api
->getSenderTimeSeries($sender['address']);
} catch (\Exception $e) {
\Drupal::logger('mandrill')
->error('An error occurred requesting sender information from Mandrill for address %address. "%message"', array(
'%address' => $sender['address'],
'%message' => $e
->getMessage(),
));
}
}
$cache
->set('senders', $data);
return $data;
}