-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheck.api.php
146 lines (132 loc) · 3.57 KB
/
eck.api.php
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
141
142
143
144
145
146
<?php
/**
* @file
* ECK's API documentation.
*/
/**
* Respond to the creation of a new ECK entity type.
*
* @param EntityType $entity_type
* The entity type is being created.
*/
function hook_eck_entity_type_insert(EntityType $entity_type) {
}
/**
* Respond to the updating of a new ECK entity type.
*
* @param EntityType $entity_type
* The entity type is being update.
*/
function hook_eck_entity_type_update(EntityType $entity_type) {
}
/**
* Respond to the deletion of a new ECK entity type.
*
* @param EntityType $entity_type
* The entity type is being deleted.
*/
function hook_eck_entity_type_delete(EntityType $entity_type) {
}
/**
* Defines default properties.
*
* A default property shows up in the property select list when a user is
* first creating an entity type. These are meant to be commonly use properties
* that we don't want to configure constantly. There is nothing special about
* default properties, they are just meant to save time.
*
* There is also an ALTER version of this hook.
*/
function hook_eck_default_properties() {
$default_properties = array();
$default_properties['machine_name'] = array(
'label' => "My Default Property",
// @see eck_property_types().
'type' => "text",
// To find all of the behaviors that are available, you can use
// ctools_get_plugins('eck', 'property_behavior');
// or look at the interface under "manage properties"
'behavior' => 'some_behavior',
);
}
/**
* Change an entity's label dynamically.
*
* More constrained versions of this hook also exist:
* hook_eck_entity_<entity_type>_label
* hook_eck_entity_<entity_type>_<bundle>_label
*
* This hook is mainly useful for dynamic labels, or for using values
* in a field as labels.
*
* If you are storing the label of the entity in a property already, you
* should modify the entity_info array's label key, instead of using this hook.
*
* @param Entity $entity
* The entity object.
* @param int $entity_id
* The id of the entity.
*
* @return mixed
* The label for the entity.
*/
function hook_eck_entity_label($entity, $entity_id) {
return "Somethins that should be the label for this entity";
}
/**
* Define new property types.
*
* This hook is useless without also using
* hook_eck_property_type_schema_alter().
*
* @return array
* An array with a machine name and a label for a new property type.
*/
function hook_eck_property_types() {
return array("email" => t("Email"));
}
/**
* Give the schema for your custom properties.
*
* @param array $schema
* A schema array.
* @param string $type
* The property type.
*/
function hook_eck_property_type_schema_alter(&$schema, $type) {
if ($type == 'email') {
$schema = array(
'description' => 'An email',
'type' => 'varchar',
'length' => 256,
'not null' => TRUE,
'default' => '',
);
}
}
/**
* Set custom title for entity save message.
*
* @param string $msg
* the string to be passed on to drupal_set_message() for entity save.
* @param array $args
* array of arguments.
* @param array $context
* context array.
*/
function hook_eck_entity_save_message_alter(&$msg, $args, $context) {
$msg = 'set this variable to change save message.';
}
/**
* Set custom title for bundle save message.
*
* @param string $msg
* the string to be passed on to drupal_set_message() for entity save.
* @param array $args
* array of arguments.
* @param array $context
* context array.
*/
function hook_eck_bundle_save_message_alter(&$msg, $args, $context) {
$msg = 'set this variable to change save message.';
}