-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenviromage.module
115 lines (102 loc) · 2.92 KB
/
enviromage.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* @file
* This file shows that I could implement a hook
*/
use Drupal\Core\Form\FormStateInterface;
/**
* Implements hook_cron()
*/
function enviromage_cron(): void {
\Drupal::messenger()->addMessage(t("Hello from enviromage cron hook"));
}
/**
* Implements hook_form_alter().
*/
function enviromage_form_alter(&$form, FormStateInterface $form_state, $form_id): void {
// \Drupal::messenger()->addMessage(t("form_id of this form is @id", ['@id' => $form_id]));
if ($form_id == 'node_article_edit_form') {
$form['actions']['submit']['#value'] = t("Save this awesome article!");
}
if ($form_id === 'composer_run') {
echo "HI";
}
}
/**
* Implements hook_theme().
*/
function enviromage_theme($existing, $type, $theme, $path) {
return [
'composer_command' => [
'variables' => [
'result' => NULL,
],
],
'composer_fail' => [
'variables' => [
'status_code' => NULL,
],
],
'modules_size' => [
'variables' => [
'modules_size' => NULL,
'each_module' => NULL,
],
],
'environment_configuration' => [
'variables' => [
'environment_configuration' => NULL,
],
],
];
}
function print_array_recursive($array, $indent = '') {
foreach ($array as $key => $value) {
echo $indent . $key . ': ';
if (is_array($value)) {
print_array_recursive($value, $indent . ' ');
} else {
echo $value;
}
echo "</br>";
}
}
/**
* Implements hook_module_implements_alter
*/
//function enviromage_module_implements_alter(&$implementations, $hook) {
//// echo "<pre>";
//// $number_of_elements = count($implementations);
//// echo "${number_of_elements} </br>";
//// print_array_recursive($implementations);
// if (isset($implementations['automatic_updates'])) {
// echo '$implementations[\'automatic_updates\'] is setted.</br>';
// if (is_array($implementations['automatic_updates']))
// print_array_recursive($implementations['automatic_updates']);
// else
// echo $implementations['automatic_updates'];
// }
//// echo "</pre>";
// \Drupal::messenger()->addMessage(t("\$hook == $hook"));
// if ($hook == 'hook_help') {
// // Add your custom module's implementation of the target module's hook
// $memory_peak_usage = memory_get_peak_usage(true);
// \Drupal::messenger()->addMessage(t("The memory usage of $hook hook is @u",
// ['@u' => $memory_peak_usage]));
//// array_unshift($implementations, 'enviromage');
//// $implementations['automatic_updates'] = function() use () {};
// }
//}
/**
* Implements hook_requirements().
*/
function enviromage_name_requirements($phase) {
$requirements = [];
// Check for custom error condition.
$requirements['enviromage_error'] = [
'title' => t('Error For Free XDD!'),
'severity' => REQUIREMENT_ERROR,
'description' => t('There is an error in your custom module.'),
];
return $requirements;
}