-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacademy.module
60 lines (52 loc) · 1.22 KB
/
academy.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
<?php
/**
* @file
* Contains academy.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function academy_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the academy module.
case 'help.page.academy':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('My Awesome Module') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function academy_theme() {
return [
'academy' => [
'render element' => 'children',
],
];
}
/**
* Implements hook_form_alter().
*/
function academy_form_alter(
&$form,
\Drupal\Core\Form\FormStateInterface $form_state,
$form_id
) {
switch ($form_id) {
case 'node_article_form':
//se utente non ha permesso handle article any country =>
if (! \Drupal::currentUser()->hasPermission(
'handle article any country'
)) {
$user = \Drupal\user\Entity\User::load(Drupal::currentUser()->id());
$value = $user->field_country->value();
$form['field_country']['#access'] = FALSE;
$form['field_country']['#default_value'] = $value;
}
break;
}
}