forked from backdrop-contrib/profile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.info.inc
80 lines (71 loc) · 2.45 KB
/
profile.info.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
<?php
/**
* @file
* Provides Entity metadata integration.
*/
/**
* Extend the defaults.
*/
class ProfileMetadataController extends EntityDefaultMetadataController {
public function entityPropertyInfo() {
$info = parent::entityPropertyInfo();
$properties = &$info[$this->type]['properties'];
$properties['label'] = array(
'label' => t('Label'),
'description' => t('The profile label.'),
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer profiles',
'schema field' => 'label',
);
$properties['type'] = array(
'type' => 'profile_type',
'getter callback' => 'entity_property_getter_method',
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer profiles',
'required' => TRUE,
'description' => t('The profile type.'),
) + $properties['type'];
unset($properties['uid']);
$properties['user'] = array(
'label' => t("User"),
'type' => 'user',
'description' => t("The owner of the profile."),
'getter callback' => 'entity_property_getter_method',
'setter callback' => 'entity_property_setter_method',
'setter permission' => 'administer profiles',
'required' => TRUE,
'schema field' => 'uid',
);
$properties['created'] = array(
'label' => t("Date created"),
'type' => 'date',
'description' => t("The date the profile was created."),
'setter callback' => 'entity_property_verbatim_set',
'setter permission' => 'administer profiles',
'schema field' => 'created',
);
$properties['changed'] = array(
'label' => t("Date changed"),
'type' => 'date',
'schema field' => 'changed',
'description' => t("The date the profile was most recently updated."),
);
return $info;
}
}
/**
* Implements hook_entity_property_info_alter().
*/
function profile_entity_property_info_alter(&$info) {
// Add related profiles to the user object.
$properties = &$info['user']['properties'];
foreach (profile_get_types() as $type_name => $type) {
$properties['profile_' . $type_name] = array(
'type' => 'profile',
'label' => t('@type_name profile', array('@type_name' => backdrop_ucfirst($type->label))),
'description' => t("The users's @type_name profile.", array('@type_name' => $type->label)),
'getter callback' => 'profile_user_get_properties',
'bundle' => $type_name,
);
}
}