-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathetree.module
More file actions
126 lines (109 loc) · 3.32 KB
/
etree.module
File metadata and controls
126 lines (109 loc) · 3.32 KB
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
<?php
/**
* @file
* Contains etree.module.
*/
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Drupal\etree\Entity\ETreeType;
/**
* Implements hook_help().
*/
function etree_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the etree module.
case 'help.page.etree':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Entity Tree module') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function etree_theme() {
$theme = [];
$theme['etree_collection_page'] = [
'variables' => ['collection' => NULL, 'overview' => NULL],
'file' => 'etree.page.inc',
'template' => 'etree-collection-page',
];
$theme['etree'] = [
'render element' => 'elements',
'file' => 'etree.page.inc',
'template' => 'etree',
];
$theme['etree_content_add_list'] = [
'render element' => 'content',
'variables' => ['content' => NULL],
'file' => 'etree.page.inc',
];
return $theme;
}
/**
* Implements hook_theme_suggestions_HOOK().
*/
function etree_theme_suggestions_etree(array $variables) {
$suggestions = [];
/** @var \Drupal\etree\Entity\ETreeInterface $entity */
$entity = $variables['elements']['#etree'];
$sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
$suggestions[] = 'etree__' . $sanitized_view_mode;
$suggestions[] = 'etree__' . $entity->bundle();
$suggestions[] = 'etree__' . $entity->bundle() . '__' . $sanitized_view_mode;
$suggestions[] = 'etree__' . $entity->id();
$suggestions[] = 'etree__' . $entity->id() . '__' . $sanitized_view_mode;
return $suggestions;
}
/**
* Implements hook_entity_operation_alter().
*/
function etree_entity_operation_alter(array &$operations, EntityInterface $entity) {
// $modal_configs = [
// 'entity.etree.edit_form' => TRUE,
// 'entity.etree.add_form' => TRUE,
// 'entity.etree.canonical' => TRUE,
// ];
//
//
// foreach ($operations as &$operation) {
// /** @var Url $url */
// $route_name = $operation['url']->getRouteName();
// if (!isset($modal_configs[$route_name]) || FALSE === $modal_configs[$route_name]) {
// continue;
// }
// $operation['attributes'] = ETreeCommon::linkModalAttributes();
// $operation['#attached'] = ETreeCommon::linkModalAttached();
//
// }
}
function etree_js_alter(&$javascript, \Drupal\Core\Asset\AttachedAssetsInterface $assets) {
$replace = [
'core/assets/vendor/jquery.ui/ui/widget-min.js' => 'core/assets/vendor/jquery.ui/full/widget.js',
'core/assets/vendor/jquery.ui/ui/widgets/dialog-min.js' => 'core/assets/vendor/jquery.ui/full/widgets/dialog.js',
];
// foreach ($replace as $origin => $full) {
// $javascript[$origin]['data'] = $full;
// }
}
/**
* Implements hook_entity_extra_field_info().
*/
function etree_entity_extra_field_info() {
$extra = [];
$description = t('Etree module element');
foreach (ETreeType::loadMultiple() as $bundle) {
$extra['etree'][$bundle->id()]['display']['links'] = [
'label' => t('Links'),
'description' => $description,
'weight' => 100,
'visible' => TRUE,
];
}
return $extra;
}