public function CampaignMonitorListsController::overview in Campaign Monitor 8.2
Same name and namespace in other branches
- 8 src/Controller/CampaignMonitorListsController.php \Drupal\campaignmonitor\Controller\CampaignMonitorListsController::overview()
1 string reference to 'CampaignMonitorListsController::overview'
File
- src/
Controller/ CampaignMonitorListsController.php, line 61
Class
- CampaignMonitorListsController
- Campaign Monitor Lists controller.
Namespace
Drupal\campaignmonitor\ControllerCode
public function overview() {
$content = [];
$lists_admin_url = Url::fromUri('https://waxeye.createsend.com/subscribers/', [
'attributes' => [
'target' => '_blank',
],
]);
$lists_empty_message = $this
->t("You don't have any lists configured in your\n Campaign Monitor account, (or you haven't configured your API key correctly on\n the Global Settings tab). Head over to @link and create some lists, then\n come back here and click 'Refresh lists from Campaign Monitor'", [
'@link' => Link::fromTextAndUrl($this
->t('Campaign Monitor'), $lists_admin_url)
->toString(),
]);
$content['lists_table'] = [
'#type' => 'table',
'#header' => [
$this
->t('Name'),
$this
->t('List ID'),
$this
->t('Subscribed'),
$this
->t('Operations'),
],
'#empty' => $lists_empty_message,
];
$cm_lists = $this->campaignMonitorManager
->getLists();
// $total_webhook_events = count(campaignmonitor_default_webhook_events());
foreach ($cm_lists as $key => $cm_list) {
$stats = $this->campaignMonitorManager
->getListStats($key);
$edit_link = Link::fromTextAndUrl($this
->t('Edit'), Url::fromUri('internal:/admin/config/services/campaignmonitor/list/' . $key . '/edit'))
->toString();
$delete_link = Link::fromTextAndUrl($this
->t('Delete'), Url::fromUri('internal:/admin/config/services/campaignmonitor/list/' . $key . '/delete'))
->toString();
$operations = [
'Edit' => $edit_link,
'Delete' => $delete_link,
];
$list_options = $this->campaignMonitorManager
->getListSettings($key);
if (isset($list_options['status']['enabled']) && !$list_options['status']['enabled']) {
// Add enable operation.
$link = Link::fromTextAndUrl($this
->t('Enable'), Url::fromUri('internal:/admin/config/services/campaignmonitor/list/' . $key . '/enable'))
->toString();
$operations['enable'] = $link;
}
else {
// Add disable operation.
$link = Link::fromTextAndUrl($this
->t('Disable'), Url::fromUri('internal:/admin/config/services/campaignmonitor/list/' . $key . '/disable'))
->toString();
$operations['disable'] = $link;
}
/*$enabled_webhook_events =
count(campaignmonitor_enabled_webhook_events($cm_list->id));
$webhook_url =
Url::fromRoute('campaignmonitor.webhook', ['list_id' => $cm_list->id]);
$webhook_link = Link::fromTextAndUrl('update', $webhook_url);
$webhook_status =
$enabled_webhook_events . ' of ' . $total_webhook_events .
' enabled (' . $webhook_link->toString() . ')';
$list_url = Url::fromUri(
'https://admin.campaignmonitor.com/lists/dashboard/overview?id=' .
$cm_list->id,
['attributes' => ['target' => '_blank']]);*/
$content['lists_table'][$key]['name'] = [
'#markup' => $cm_list['name'],
];
$content['lists_table'][$key]['id'] = [
'#markup' => $key,
];
$content['lists_table'][$key]['stats'] = [
'#markup' => $stats['TotalActiveSubscribers'] . ' / ' . $stats['TotalUnsubscribes'],
];
$content['lists_table'][$key]['operations'] = [
'#markup' => implode(' ', $operations),
];
}
$refresh_url = Url::fromRoute('campaignmonitor.refresh_lists', [
'destination' => 'admin/config/services/campaignmonitor/lists',
]);
$content['refresh'] = [
'#type' => 'container',
];
$content['refresh']['refresh_link'] = [
'#title' => 'Refresh lists from CampaignMonitor',
'#type' => 'link',
'#url' => $refresh_url,
];
return $content;
}