-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathjigs.module
140 lines (126 loc) · 4.03 KB
/
jigs.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
* @file
* Contains hook implementations for the jigs module.
*/
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\node\NodeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\FieldDefinition;
function jigs_page_attachments(array &$page) {
$computed_settings = [
// stuff from mysql and user objects.
'foo' => 'bar',
'baz' => 'qux',
];
//$uid = \Drupal::currentUser()->id();
$node = \Drupal::request()->get('node');
if (isset($node) && $node instanceof NodeInterface) {
$title = $node->getTitle();
$type = $node->getType();
if ($type == 'game' or $type == 'map_grid') {
$page['#attached']['library'][] = 'jigs/client';
// $page['#attached']['library'][] = 'jigs/phaser';
// if (!\Drupal::currentUser()->hasPermission('access contextual links')) {
// return;
// }
}
}
}
/**
* Implements hook_form_alter().
*/
/* function jigs_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id)
{
// if ($form_id == 'node-map-grid-form' || $form_id == 'node-map-grid-edit-form') {
$form['field_ image']['#states'] = [
'visible' => [
':input[name="field_image_or_video"]' => ['value' => 'Image'],
],
];
$form['field_ video']['#states'] = [
'visible' => [
':input[name="field_image_or_video"]' => ['value' => 'Video'],
],
];
// }
} */
/**
* Implements hook_field_create_definitions().
*/
/* function jigs_field_create_definitions_alter(array &$definitions)
{
// Define your fields here by entity type.
$definitions['node'] = [
'demo_field' => [
'name' => 'demo_field',
'label' => 'This is my field',
// 'type' => 'string',
'force' => FALSE, // No update once field exists.
'bundles' => [
'map_grid' => [],
'article' => [],
],
],
];
} */
/* function jigs_entity_bundle_field_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type, $bundle, array $base_field_definitions)
{
if ($entity_type->id() == "node" && $bundle == "concert") {
$concert_fields['laatste_uitvoering'] = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
->setLabel('Laatste uitvoering')
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', FALSE)
->setDisplayOptions('view', array(
'label' => 'inline',
// 'type' => 'datetime_plain',
'weight' => '999',
));
$concert_fields['eerste_uitvoering'] = \Drupal\Core\Field\BaseFieldDefinition::create('datetime')
->setLabel('Eerste uitvoering')
->setRequired(TRUE)
->setDisplayConfigurable('view', TRUE)
->setDisplayConfigurable('form', FALSE)
->setDisplayOptions('view', array(
'label' => 'inline',
// 'type' => 'datetime_plain',
'weight' => '999',
));
return $concert_fields;
}
} */
/*
function jigs_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type)
{
if ($entity_type->id() == 'node') {
$definitions['my_bundle_field'] = \Drupal\Core\Field\BaseFieldDefinition::create('string')
->setName('my_bundle_field')
->setLabel(t('My new bundle field'))
->setTargetEntityTypeId($entity_type->id());
return $definitions;
}
}
*/
function jigs_theme($existing, $type, $theme, $path) {
return [
'node__game' => [
'template' => 'node--game',
'base hook' => 'node',
'path' => \Drupal::service('extension.list.module')->getPath('jigs') . '/templates',
],
'profile__player__player' => [
'template' => 'profile--player--player',
'base hook' => 'profile',
'path' => \Drupal::service('extension.list.module')->getPath('jigs') . '/templates',
],
];
}
function jigs_preprocess_page(&$variables) {
if (!\Drupal::service('router.admin_context')->isAdminRoute()) {
// $variables['#attached']['library'][] = 'jigs/coreui-styles';
$variables['#attached']['library'][] = 'jigs/jigs-theme';
}
}