public function CampaignMonitorCampaignController::campaignsOverview in Campaign Monitor 8
File
- src/
Controller/ CampaignMonitorCampaignController.php, line 18
Class
- CampaignMonitorCampaignController
- Campaign Monitor Lists controller.
Namespace
Drupal\campaignmonitor\ControllerCode
public function campaignsOverview() {
$content = [];
$campaigns_admin_url = Url::fromUri('https://waxeye.createsend.com/subscribers/', [
'attributes' => [
'target' => '_blank',
],
]);
$campaigns_empty_message = t('You don\'t have any campaigns configured in your
Campaign Monitor account, (or you haven\'t configured your API key correctly on
the Global Settings tab). Head over to @link and create some campaigns, then
come back here and click "Refresh campaigns from Campaign Monitor"', [
'@link' => Link::fromTextAndUrl(t('Campaign Monitor'), $campaigns_admin_url)
->toString(),
]);
$content['campaigns_table'] = [
'#type' => 'table',
'#header' => [
t('Name'),
t('Sent'),
t('Link'),
],
'#empty' => $campaigns_empty_message,
];
$cm_campaigns = campaignmonitor_campaign_get_campaigns();
foreach ($cm_campaigns as $key => $cm_campaign) {
// $details = campaignmonitor_get_list_details($key);
// $stats = campaignmonitor_get_list_stats($key);
$content['campaigns_table'][$key]['name'] = [
'#markup' => $cm_campaign['Name'],
];
$content['campaigns_table'][$key]['sent'] = [
'#markup' => $cm_campaign['Sent'],
];
$content['campaigns_table'][$key]['link'] = [
'#markup' => $cm_campaign['Link'],
];
// $content['campaigns_table'][$key]['operations'] = array(
// '#markup' => implode(' ', $operations),
//
// );.
}
$refresh_url = Url::fromRoute('campaignmonitor.refresh_campaigns', [
'destination' => 'admin/config/services/campaignmonitor/campaigns',
]);
$content['refresh'] = [
'#type' => 'container',
];
$content['refresh']['refresh_link'] = [
'#title' => 'Refresh campaigns from Campaign Monitor',
'#type' => 'link',
'#url' => $refresh_url,
];
// $create_url = Url::fromRoute('campaignmonitor.list_create_form', array('destination' => 'admin/config/services/campaignmonitor/campaigns'));
//
// $content['create'] = array(
// '#type' => 'container'
// );
//
// $content['create']['create_link'] = array(
// '#title' => 'Create a new list',
// '#type' => 'link',
// '#url' => $create_url
// );.
return $content;
}