-
Notifications
You must be signed in to change notification settings - Fork 5
/
my_entity.api.inc
101 lines (85 loc) · 2.53 KB
/
my_entity.api.inc
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
<?php
/**
* @file
* API functions related to My Entity entity.
*/
/*******************************************************************************
********************************* My Entity API's *******************************
******************************************************************************/
/**
* Access callback for My Entity.
*/
function my_entity_access($op, $my_entity, $account = NULL) {
return entity_boilerplate_entity_access($op, $my_entity, $account, 'my_entity');
}
/**
* Load a My Entity.
*/
function my_entity_load($eid, $reset = FALSE) {
$my_entities = my_entity_load_multiple(array($eid), array(), $reset);
return reset($my_entities);
}
/**
* Load multiple My Entity based on certain conditions.
*/
function my_entity_load_multiple($eids = array(), $conditions = array(), $reset = FALSE) {
return entity_load('my_entity', $eids, $conditions, $reset);
}
/**
* Save My Entity.
*/
function my_entity_save($my_entity) {
entity_save('my_entity', $my_entity);
}
/**
* Delete single My Entity.
*/
function my_entity_delete($my_entity) {
entity_delete('my_entity', entity_id('my_entity', $my_entity));
}
/**
* Delete multiple My Entitys.
*/
function my_entity_delete_multiple($eids) {
entity_delete_multiple('my_entity', $eids);
}
/*******************************************************************************
****************************** My Entity Type API's *****************************
******************************************************************************/
/**
* Access callback for My Entity Type.
*/
function my_entity_type_access($op, $entity = NULL, $account = NULL) {
return user_access('administer my_entity_type entities', $account);
}
/**
* Load My Entity Type.
*/
function my_entity_type_load($my_entity_type) {
return my_entity_types($my_entity_type);
}
/**
* List of My Entity Types.
*/
function my_entity_types($type_name = NULL) {
$types = entity_load_multiple_by_name('my_entity_type', isset($type_name) ? array($type_name) : FALSE);
return isset($type_name) ? reset($types) : $types;
}
/**
* Save My Entity Type entity.
*/
function my_entity_type_save($my_entity_type) {
entity_save('my_entity_type', $my_entity_type);
}
/**
* Delete single My Entity type.
*/
function my_entity_type_delete($my_entity_type) {
entity_delete('my_entity_type', entity_id('my_entity_type', $my_entity_type));
}
/**
* Delete multiple My Entity types.
*/
function my_entity_type_delete_multiple($my_entity_type_ids) {
entity_delete_multiple('my_entity_type', $my_entity_type_ids);
}