public function CampaignMonitorUserController::subscriptionPage in Campaign Monitor 8
Same name and namespace in other branches
- 8.2 modules/campaignmonitor_user/src/Controller/CampaignMonitorUserController.php \Drupal\campaignmonitor_user\Controller\CampaignMonitorUserController::subscriptionPage()
View subscriptions.
This controller assumes that it is only invoked for authenticated users. This is enforced for the 'user.page' route with the '_user_is_logged_in' requirement.
File
- modules/
campaignmonitor_user/ src/ Controller/ CampaignMonitorUserController.php, line 84
Class
- CampaignMonitorUserController
- Controller routines for user routes.
Namespace
Drupal\campaignmonitor_user\ControllerCode
public function subscriptionPage() {
// Get the user's current subscriptions.
$current_user = \Drupal::currentUser();
$config = \Drupal::config('campaignmonitor_user.settings');
$email = $current_user
->getEmail();
$subscriptions = campaignmonitor_user_get_user_subscriptions($email, 'names');
$subscriptions_empty_message = '';
$content['subscription_heading'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'subscription-heading',
],
],
];
$content['subscription_heading']['heading'] = [
'#markup' => $config
->get('subscription_heading'),
];
$content['subscription_text'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'subscription-text',
],
],
];
$content['subscription_text']['text'] = [
'#markup' => $config
->get('subscription_text'),
];
$content['subscriptions_table'] = [
'#type' => 'table',
'#header' => [
t('Name'),
],
'#empty' => $subscriptions_empty_message,
];
foreach ($subscriptions as $list_id => $name) {
$content['subscriptions_table'][$list_id]['name'] = [
'#markup' => $name,
];
}
return [
'#theme' => 'campaignmonitor_user_profile',
'#content' => $content,
'#cache' => [
'contexts' => [
'user',
],
],
];
}