-
Notifications
You must be signed in to change notification settings - Fork 17
/
openy_memberships.module
95 lines (80 loc) · 2.22 KB
/
openy_memberships.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* @file
* Open Y Memberships module file.
*/
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\openy_memberships\Plugin\Field\FieldType\LearnMoreExtraField;
/**
* Implements hook_menu_links_discovered_alter().
*/
function openy_memberships_menu_links_discovered_alter(&$links) {
// Move the Commerce links to the Memberships menu.
$links['commerce.admin_commerce']['parent'] = 'openy_memberships.openy_memberships';
}
/**
* Implements hook_page_attachments().
*/
function openy_memberships_page_attachments(array &$page) {
$page['#attached']['library'][] = 'openy_memberships/library';
}
/**
* Implements hook_theme().
*/
function openy_memberships_theme() {
return [
'openy_memberships__pdf__summary' => [
'variables' => [
'content' => [],
],
],
];
}
/**
* @param $key
* @param $message
* @param $params
* Implements hook_mail()
*/
function openy_memberships_mail($key, &$message, $params) {
switch ($key) {
case 'openy_memberships_summary_email':
$headers = [
'MIME-Version' => '1.0',
'Content-Type' => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Open Y',
];
foreach ($headers as $key => $value) {
$message['headers'][$key] = $value;
}
$message['subject'] = $params['subject'];
$message['body'][] = $params['message'];
break;
}
}
/**
* Implements hook_entity_type_view().
*/
function openy_memberships_commerce_product_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
if ($entity->bundle() != 'membership') {
return;
}
if ($view_mode != 'teaser') {
return;
}
\Drupal::service('class_resolver')
->getInstanceFromDefinition(LearnMoreExtraField::class)
->fieldAttach($build, $entity, $display);
}
/**
* Implements hook_entity_extra_field_info().
*/
function openy_memberships_entity_extra_field_info() {
$extra = [];
\Drupal::service('class_resolver')
->getInstanceFromDefinition(LearnMoreExtraField::class)
->addExtraField($extra);
return $extra;
}