-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscribe.module
42 lines (41 loc) · 1.9 KB
/
subscribe.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* @File
* Subscribe module for Drupal 8.
* @author Ahmed Raza
*/
function subscribe_element_info_alter(array &$types) {
$types['table']['#attached']['library'][] = 'subscribe/subscribe.lib';
}
/**
* @File
* hook_mail for subscription mails.
*/
function subscribe_mail($key, &$message, $params) {
$options = array(
'langcode' => $message['langcode'],
);
switch ($key) {
case 'subscribe_submit':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('Subscribe Confirmation');
$message['body'][] = "Dear " . $params['name'] . "!";
$message['body'][] = t("You received this confirmation email for @email from @site. To confirm subscription please goto to the following link.", array('@email'=>$params['email'], '@site'=>\Drupal::config('system.site')->get('name')));
$message['body'][] = "Link: " . $params['link'];
break;
case 'subscribe_resend':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('Resend Subscribe Confirmation');
$message['body'][] = "Dear " . $params['name'] . "!";
$message['body'][] = t("You received this confirmation email for @email from @site. To confirm subscription please goto to the following link.", array('@email'=>$params['email'], '@site'=>\Drupal::config('system.site')->get('name')));
$message['body'][] = "Link: " . $params['link'];
break;
case 'subscribe_remove':
$message['from'] = \Drupal::config('system.site')->get('mail');
$message['subject'] = t('Unsubscribe');
$message['body'][] = "Dear " . $params['name'] . "!";
$message['body'][] = t("You received this confirmation email for @email from @site. To confirm subscription please goto to the following link.", array('@email'=>$params['email'], '@site'=>\Drupal::config('system.site')->get('name')));
$message['body'][] = "Link: " . $params['link'];
break;
}
}