forked from ding2/ding_entity
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathding_entity.field.inc
More file actions
66 lines (60 loc) · 1.43 KB
/
ding_entity.field.inc
File metadata and controls
66 lines (60 loc) · 1.43 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
<?php
/**
* @file
* Field hook implementations.
*/
/**
* Implements hook_field_info().
*/
function ding_entity_field_info() {
return array(
'ding_entity_buttons' => array(
'label' => t('Action buttons.'),
'description' => t('Action buttons.'),
'default_widget' => 'hidden',
'default_formatter' => 'ding_entity_buttons_default',
'no_ui' => TRUE,
),
);
}
/**
* Implements hook_field_load().
*/
function ding_entity_field_load($entity_type, $entities, $field, $instances, $langcode, &$items, $age) {
foreach ($entities as $id => $entity) {
$items[$id][0] = array(
'id' => $id,
);
}
}
/**
* Implements hook_widget_info_alter().
*/
function ding_entity_widget_info_alter(&$info) {
if (isset($info['hidden'])) {
$info['hidden']['field types'][] = 'ding_entity_buttons';
}
}
/**
* Implements hook_field_formatter_info().
*/
function ding_entity_field_formatter_info() {
return array(
'ding_entity_buttons_default' => array(
'label' => t('Default'),
'field types' => array(
'ding_entity_buttons',
),
)
);
}
/**
* Implements hook_field_formatter_view().
*/
function ding_entity_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
foreach ($items as $delta => $item) {
$element[$delta] = module_invoke_all('ding_entity_buttons', 'ding_entity', $entity);
}
return $element;
}